Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1 | define( |
| 2 | ['containermenu', 'menu/item', 'menu/prefix', 'menu/lengthField','container/containeritem','container/container'], |
| 3 | function (containerMenuClass, menuItemClass, prefixClass, lengthFieldClass, containerItemClass, containerClass) { |
| 4 | |
| 5 | // The OwnMenu item |
| 6 | const OwnMenuItem = { |
| 7 | create : function (params) { |
| 8 | return Object.create(menuItemClass).upgradeTo(OwnMenuItem)._init(params); |
| 9 | }, |
| 10 | content : function (content) { |
| 11 | if (arguments.length === 1) { |
| 12 | this._content = content; |
| 13 | }; |
| 14 | return this._content; |
| 15 | }, |
| 16 | _init : function (params) { |
| 17 | if (params[0] === undefined) |
| 18 | throw new Error("Missing parameters"); |
| 19 | |
| 20 | this._content = document.createTextNode(params[0]); |
| 21 | this._lcField = ' ' + this.content().textContent.toLowerCase(); |
| 22 | |
| 23 | return this; |
| 24 | } |
| 25 | }; |
| 26 | |
| 27 | /** |
| 28 | * Create own conainerItem class. |
| 29 | */ |
| 30 | const OwnContainerItemClass = { |
| 31 | create : function () { |
| 32 | var obj = containerItemClass.create() |
| 33 | .upgradeTo(OwnContainerItemClass); |
| 34 | //._init(); |
| 35 | obj.value=""; |
| 36 | return obj; |
| 37 | }, |
| 38 | add : function (letter) { |
| 39 | this.value+=letter; |
| 40 | }, |
| 41 | clear : function () { |
| 42 | this.value = ""; |
| 43 | }, |
| 44 | further : function () { |
| 45 | this.value = this.value + this.value; |
| 46 | }, |
| 47 | onclick : function () { |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 48 | } |
| 49 | }; |
| 50 | |
| 51 | //List of items. |
| 52 | var ExampleItemList = new Array; |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 53 | ExampleItemList.push({value : "CIValue1" , defaultTextValue : "CIText1 "}); |
| 54 | ExampleItemList.push({value : "CIValue2" , defaultTextValue : "CIText2 "}); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 55 | |
| 56 | //Own container class. |
| 57 | const OwnContainerClass = { |
| 58 | create : function (listOfContainerItems, params) { |
| 59 | //console.log(containerClass); |
| 60 | return containerClass.create(listOfContainerItems, params) |
| 61 | .upgradeTo(OwnContainerClass); |
| 62 | } |
| 63 | }; |
| 64 | |
| 65 | const OwnContainerMenu = { |
| 66 | create : function (list, containerList) { |
| 67 | const params = { |
| 68 | itemClass : OwnMenuItem, |
| 69 | prefixClass : prefixClass, |
| 70 | lengthFieldClass : lengthFieldClass, |
| 71 | containerClass : OwnContainerClass, |
| 72 | containerItemClass : OwnContainerItemClass |
| 73 | }; |
| 74 | var obj = containerMenuClass.create(list,params,containerList) |
| 75 | .upgradeTo(OwnContainerMenu); |
| 76 | //._init(list, params); |
| 77 | return obj; |
| 78 | } |
| 79 | }; |
| 80 | |
Leo Repp | c66268e | 2021-10-28 11:44:35 +0200 | [diff] [blame] | 81 | describe('KorAP.ContainerMenu', function () { |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 82 | |
| 83 | var list = [ |
| 84 | ["Constituency"], |
| 85 | ["Lemma"], |
| 86 | ["Morphology"], |
| 87 | ["Part-of-Speech"], |
| 88 | ["Syntax"] |
| 89 | ]; |
| 90 | |
| 91 | var listWithEX = [ |
| 92 | ["example 1 Constituency"], |
| 93 | ["Lemma"], |
| 94 | ["example 2 Morphology"], |
| 95 | ["Part-of_Speech"], |
| 96 | ["Syntax"] |
| 97 | ]; |
| 98 | |
| 99 | var listMultiPrefix = [ |
| 100 | ["Personal Pronoun"], |
| 101 | ["Personal Pronoun, Plural"], |
| 102 | ["Personal Pronoun, Plural, Acc."], |
| 103 | ["Personal Pronoun, Plural, Dative"], |
| 104 | ["Personal Pronoun, Plural, Direct"], |
| 105 | ["Personal Pronoun, Plural, Oblique"], |
| 106 | ["Personal Pronoun, Singular"], |
| 107 | ["Personal Pronoun, Singular, Accusative"], |
| 108 | ["Personal Pronoun, Singular, Dative"], |
| 109 | ["Personal Pronoun, Singular, Direct"], |
| 110 | ["Personal Pronoun, Singular, Nominative"], |
| 111 | ["Personal Pronoun, Singular, Oblique"] |
| 112 | ]; |
| 113 | |
| 114 | var demolist = [ |
| 115 | ['Titel'], |
| 116 | ['Untertitel'], |
| 117 | ['Veröffentlichungsdatum'], |
| 118 | ['Länge'], |
| 119 | ['Autor'] |
| 120 | ]; |
| 121 | |
| 122 | var demolonglist = [ |
| 123 | ['Titel'], |
| 124 | ['Untertitel'], |
| 125 | ['Veröffentlichungsdatum'], |
| 126 | ['Länge'], |
| 127 | ['Autor'], |
| 128 | ['Genre'], |
| 129 | ['corpusID'], |
| 130 | ['docID'], |
| 131 | ['textID'], |
| 132 | ]; |
| 133 | |
| 134 | it('should be initializable', function () { |
| 135 | /**var list = [ |
| 136 | ["Constituency"], |
| 137 | ["Lemma"], |
| 138 | ["Morphology"], |
| 139 | ["Part-of-Speech"], |
| 140 | ["Syntax"] |
| 141 | ]; |
| 142 | */ |
| 143 | |
| 144 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 145 | // This is the same with and without additional container items! |
| 146 | expect(menu.dontHide).toBe(false); |
| 147 | menu._firstActive = true; |
| 148 | expect(menu.itemClass()).toEqual(OwnMenuItem); |
| 149 | expect(menu.element().nodeName).toEqual('UL'); |
| 150 | expect(menu.element().classList.contains('visible')).toBeFalsy(); |
| 151 | expect(menu.container().element().classList.contains('visible')).toBeFalsy(); |
| 152 | expect(menu.limit()).toEqual(8); |
| 153 | expect(menu._notItemElements).toEqual(3); |
| 154 | |
| 155 | menu.limit(9); |
| 156 | expect(menu.limit()).toEqual(9); |
| 157 | |
| 158 | menu.limit(8); |
| 159 | |
| 160 | // view |
| 161 | menu.show(); |
| 162 | expect(menu.element().classList.contains('visible')).toBeTruthy(); |
| 163 | expect(menu.container().element().classList.contains('visible')).toBeTruthy(); |
| 164 | |
| 165 | // First element in list |
| 166 | expect(menu.item(0).active()).toBe(true); |
| 167 | expect(menu.item(0).noMore()).toBe(true); |
| 168 | |
| 169 | // Middle element in list |
| 170 | expect(menu.item(2).active()).toBe(false); |
| 171 | expect(menu.item(2).noMore()).toBe(false); |
| 172 | |
| 173 | // Last element in list |
| 174 | expect(menu.item(menu.length() - 1).active()).toBe(false); |
| 175 | expect(menu.item(menu.length() - 1).noMore()).toBe(true); |
| 176 | |
| 177 | expect(menu.element().classList.contains('containermenu')).toBeTruthy(); |
| 178 | expect(menu.container()).toBeTruthy(); |
| 179 | expect(menu._container.element().nodeName).toEqual('UL'); // actually need new one for container! |
| 180 | expect(menu._prefix.element().nodeName).toEqual('SPAN'); |
| 181 | expect(menu._container._containerItemClass).toEqual(OwnContainerItemClass); |
| 182 | expect(menu._container.items.length).toEqual(3); |
| 183 | }); |
| 184 | |
| 185 | it('should have a reference to the menu', function () { |
| 186 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 187 | expect(menu.item(0).menu()).toEqual(menu); |
| 188 | expect(menu.element().menu).toEqual(menu); |
| 189 | for (item of menu._container.items) { |
| 190 | expect(item._menu).toEqual(menu); |
| 191 | }; |
| 192 | }); |
| 193 | |
| 194 | |
| 195 | it('should be visible', function () { |
| 196 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 197 | expect(menu.removeItems()).toBe(undefined); |
| 198 | menu.limit(3); |
| 199 | |
| 200 | expect(menu.show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 201 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 202 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 203 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 204 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 205 | expect(liElements[3]).toBe(undefined); |
| 206 | |
| 207 | // Check boundaries |
| 208 | expect(liElements[0].classList.contains("no-more")).toBe(true); |
| 209 | expect(liElements[1].classList.contains("no-more")).toBe(false); |
| 210 | expect(liElements[2].classList.contains("no-more")).toBe(false); |
| 211 | |
| 212 | var items = menu.container().items; |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 213 | expect(items[0].content().nodeValue).toEqual("CIText1 "); |
| 214 | expect(items[1].content().nodeValue).toEqual("CIText2 "); |
| 215 | expect(items[2].element().innerHTML).toEqual(""); //prefix! |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 216 | expect(items[3]).toBe(undefined); |
| 217 | }); |
| 218 | |
| 219 | it('should be filterable', function () { |
| 220 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 221 | menu.limit(3); |
| 222 | expect(menu.prefix("o").show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 223 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 224 | expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("o"); |
| 225 | expect(liElements[0].innerHTML).toEqual("C<mark>o</mark>nstituency"); |
| 226 | expect(liElements[1].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 227 | expect(liElements[2].innerHTML).toEqual("Part-<mark>o</mark>f-Speech"); |
| 228 | expect(liElements[3]).toBe(undefined); |
| 229 | |
| 230 | // Check boundaries |
| 231 | expect(liElements[0].classList.contains("no-more")).toBe(true); |
| 232 | expect(liElements[1].classList.contains("no-more")).toBe(false); |
| 233 | expect(liElements[2].classList.contains("no-more")).toBe(true); |
| 234 | |
| 235 | menu.limit(2); |
| 236 | |
| 237 | expect(menu.prefix("o").show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 238 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 239 | expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("o"); |
| 240 | expect(liElements[0].innerHTML).toEqual("C<mark>o</mark>nstituency"); |
| 241 | expect(liElements[1].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 242 | |
| 243 | expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("o"); |
| 244 | expect(liElements[2]).toBe(undefined); |
| 245 | |
| 246 | // Check boundaries |
| 247 | expect(liElements[0].classList.contains("no-more")).toBe(true); |
| 248 | expect(liElements[1].classList.contains("no-more")).toBe(false); |
| 249 | expect(liElements[2]).toBe(undefined); |
| 250 | |
| 251 | expect(menu.prefix("e").show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 252 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 253 | expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("e"); |
| 254 | expect(liElements[0].innerHTML).toEqual("Constitu<mark>e</mark>ncy"); |
| 255 | expect(liElements[2]).toBe(undefined); |
| 256 | |
| 257 | menu.limit(5); |
| 258 | expect(menu.prefix("a").show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 259 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 260 | expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("a"); |
| 261 | expect(liElements[0].innerHTML).toEqual("Lemm<mark>a</mark>"); |
| 262 | expect(liElements[1].innerHTML).toEqual("P<mark>a</mark>rt-of-Speech"); |
| 263 | expect(liElements[2].innerHTML).toEqual("Synt<mark>a</mark>x"); |
| 264 | expect(liElements[3]).toBe(undefined); |
| 265 | |
| 266 | }); |
Leo Repp | 050a734 | 2021-10-25 11:05:32 +0200 | [diff] [blame] | 267 | |
| 268 | it('should switch to the containers prefix whenever the prefix filters the regular list to be empty', function () { |
| 269 | /**var list = [ |
| 270 | ["Constituency"], |
| 271 | ["Lemma"], |
| 272 | ["Morphology"], |
| 273 | ["Part-of-Speech"], |
| 274 | ["Syntax"] |
| 275 | ]; |
| 276 | */ |
| 277 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 278 | menu.container().add("1"); |
| 279 | menu.show(); // Simulates Buttonpress 1 |
| 280 | // See function _keypress in containermenu.js (line 147) |
| 281 | expect(menu.liveItem()).toBeUndefined(); // no elements in list match "1" |
| 282 | expect(menu.container().active()).toBeTruthy(); //thus switch to container |
| 283 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
| 284 | expect(liElements).toEqual([]); |
| 285 | expect(menu.container().liveLength()).toEqual(3); //CI1 and 2, prefix |
| 286 | expect(menu._prefix.active()).toBeTruthy(); // HERE ONLY |
| 287 | // We want whichever container item was active before |
| 288 | // to stay active, default to prefix if none was. |
| 289 | |
| 290 | //simulate _keydown(...) see containermenu.js line 137 |
| 291 | menu.container().chop(); |
| 292 | menu.show(); |
| 293 | menu.prev(); |
| 294 | expect(menu._prefix.active()).toBeFalsy(); |
| 295 | expect(menu.container().item(1).active().toBeTruthy); // at location 1: CIItem 2 |
| 296 | expect(menu.liveLength()).toEqual(5); |
| 297 | |
| 298 | menu.container().add("1"); |
| 299 | menu.show(); // Simulates Buttonpress 1 |
| 300 | // See function _keypress in containermenu.js (line 147) |
| 301 | expect(menu.liveItem()).toBeUndefined(); // no elements in list match "1" |
| 302 | expect(menu.container().active()).toBeTruthy(); |
| 303 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
| 304 | expect(liElements).toEqual([]); |
| 305 | expect(menu.container().liveLength()).toEqual(3); //CI1 and 2, prefix |
| 306 | expect(menu.container().item(1).active().toBeTruthy); // at location 1: CIItem 2 |
| 307 | // We want whichever container item was active before |
| 308 | // to stay active, default to prefix if none was. |
| 309 | |
| 310 | }); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 311 | |
Leo Repp | c66268e | 2021-10-28 11:44:35 +0200 | [diff] [blame] | 312 | it('should allow removing an item from the container list', function () {/**var list = [ |
| 313 | ["Constituency"], |
| 314 | ["Lemma"], |
| 315 | ["Morphology"], |
| 316 | ["Part-of-Speech"], |
| 317 | ["Syntax"] |
| 318 | ]; |
| 319 | */ |
| 320 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 321 | menu._firstActive = true; |
| 322 | menu.limit(3); |
| 323 | expect(menu.show()).toBe(true); |
| 324 | menu.next(); |
| 325 | menu.next(); |
| 326 | menu.next(); |
| 327 | menu.next(); |
| 328 | expect(menu.shownItem(2).active()).toBe(true); |
| 329 | expect(menu.container().item(0).active()).toBe(false); |
| 330 | expect(menu.container().item(1).active()).toBe(false); |
| 331 | expect(menu.container().item(2).active()).toBe(false); //prefix |
| 332 | expect(menu.container().item(2)).toEqual(menu._prefix); |
| 333 | expect(menu.container().length()).toBe(3); |
| 334 | menu.container().removeItemByIndex(0); |
| 335 | expect(menu.shownItem(2).active()).toBe(true); |
| 336 | expect(menu.container().item(0).active()).toBe(false); |
| 337 | expect(menu.container().item(1).active()).toBe(false); //prefix |
| 338 | expect(menu.container().item(1)).toEqual(menu._prefix); |
| 339 | expect(menu.container().length()).toBe(2); |
| 340 | menu.next(); |
| 341 | expect(menu.shownItem(2).active()).toBe(false); |
| 342 | expect(menu.container().item(0).active()).toBe(true); |
| 343 | expect(menu.container().item(1).active()).toBe(false); //prefix |
| 344 | expect(menu.container().item(1)).toEqual(menu._prefix); |
| 345 | expect(menu.container().length()).toBe(2); |
| 346 | menu.container().removeItemByIndex(0); |
| 347 | expect(menu.shownItem(2).active()).toBe(false); |
| 348 | expect(menu.shownItem(0).active()).toBe(true); |
| 349 | expect(menu.container().item(0).active()).toBe(false); //prefix //would be selected, if it were not "" |
| 350 | expect(menu.container().item(0)).toEqual(menu._prefix); |
| 351 | expect(menu.container().length()).toBe(1); |
| 352 | |
| 353 | |
| 354 | |
| 355 | }); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 356 | it('should be nextable', function () { |
| 357 | var menu = OwnContainerMenu.create(list); |
| 358 | menu._firstActive = true; |
| 359 | |
| 360 | // Show only 3 items |
| 361 | menu.limit(3); |
| 362 | expect(menu.show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 363 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 364 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 365 | expect(menu.shownItem(0).active()).toBe(true); |
| 366 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 367 | expect(menu.shownItem(1).active()).toBe(false); |
| 368 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 369 | expect(menu.shownItem(2).active()).toBe(false); |
| 370 | expect(liElements[3]).toBe(undefined); |
| 371 | |
| 372 | // Activate next (1) |
| 373 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 374 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 375 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 376 | expect(menu.shownItem(0).active()).toBe(false); |
| 377 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 378 | expect(menu.shownItem(1).active()).toBe(true); |
| 379 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 380 | expect(menu.shownItem(2).active()).toBe(false); |
| 381 | expect(liElements[3]).toBe(undefined); |
| 382 | |
| 383 | // Activate next (2) |
| 384 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 385 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 386 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 387 | expect(menu.shownItem(0).active()).toBe(false); |
| 388 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 389 | expect(menu.shownItem(1).active()).toBe(false); |
| 390 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 391 | expect(menu.shownItem(2).active()).toBe(true); |
| 392 | expect(liElements[3]).toBe(undefined); |
| 393 | |
| 394 | // Activate next (3) |
| 395 | // scroll! |
| 396 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 397 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 398 | expect(liElements[0].innerHTML).toEqual("Lemma"); |
| 399 | expect(menu.shownItem(0).active()).toBe(false); |
| 400 | expect(liElements[1].innerHTML).toEqual("Morphology"); |
| 401 | expect(menu.shownItem(1).active()).toBe(false); |
| 402 | expect(liElements[2].innerHTML).toEqual("Part-of-Speech"); |
| 403 | expect(menu.shownItem(2).active()).toBe(true); |
| 404 | expect(liElements[3]).toBe(undefined); |
| 405 | |
| 406 | // Activate next (4) |
| 407 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 408 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 409 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 410 | expect(menu.shownItem(0).active()).toBe(false); |
| 411 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 412 | expect(menu.shownItem(1).active()).toBe(false); |
| 413 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 414 | expect(menu.shownItem(2).active()).toBe(true); |
| 415 | expect(liElements[3]).toBe(undefined); |
| 416 | |
| 417 | // Activate next (5) - ROLL |
| 418 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 419 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 420 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 421 | expect(menu.shownItem(0).active()).toBe(true); |
| 422 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 423 | expect(menu.shownItem(1).active()).toBe(false); |
| 424 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 425 | expect(menu.shownItem(2).active()).toBe(false); |
| 426 | expect(liElements[3]).toBe(undefined); |
| 427 | |
| 428 | // Active next (6) |
| 429 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 430 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 431 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 432 | expect(menu.shownItem(0).active()).toBe(false); |
| 433 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 434 | expect(menu.shownItem(1).active()).toBe(true); |
| 435 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 436 | expect(menu.shownItem(2).active()).toBe(false); |
| 437 | expect(liElements[3]).toBe(undefined); |
| 438 | }); |
| 439 | |
| 440 | it('should be nextable when there are two containeritems', function () { |
| 441 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 442 | menu._firstActive = true; |
| 443 | |
| 444 | // Show only 3 items |
| 445 | menu.limit(3); |
| 446 | expect(menu.show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 447 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 448 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 449 | expect(menu.shownItem(0).active()).toBe(true); |
| 450 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 451 | expect(menu.shownItem(1).active()).toBe(false); |
| 452 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 453 | expect(menu.shownItem(2).active()).toBe(false); |
| 454 | expect(liElements[3]).toBe(undefined); |
| 455 | expect(menu.container().items[0].active()).toBe(false); |
| 456 | expect(menu.container().items[1].active()).toBe(false); |
| 457 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 458 | |
| 459 | // Activate next (1) |
| 460 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 461 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 462 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 463 | expect(menu.shownItem(0).active()).toBe(false); |
| 464 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 465 | expect(menu.shownItem(1).active()).toBe(true); |
| 466 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 467 | expect(menu.shownItem(2).active()).toBe(false); |
| 468 | expect(liElements[3]).toBe(undefined); |
| 469 | expect(menu.container().items[0].active()).toBe(false); |
| 470 | expect(menu.container().items[1].active()).toBe(false); |
| 471 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 472 | |
| 473 | // Activate next (2) |
| 474 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 475 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 476 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 477 | expect(menu.shownItem(0).active()).toBe(false); |
| 478 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 479 | expect(menu.shownItem(1).active()).toBe(false); |
| 480 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 481 | expect(menu.shownItem(2).active()).toBe(true); |
| 482 | expect(liElements[3]).toBe(undefined); |
| 483 | expect(menu.container().items[0].active()).toBe(false); |
| 484 | expect(menu.container().items[1].active()).toBe(false); |
| 485 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 486 | |
| 487 | // Activate next (3) |
| 488 | // scroll! |
| 489 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 490 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 491 | expect(liElements[0].innerHTML).toEqual("Lemma"); |
| 492 | expect(menu.shownItem(0).active()).toBe(false); |
| 493 | expect(liElements[1].innerHTML).toEqual("Morphology"); |
| 494 | expect(menu.shownItem(1).active()).toBe(false); |
| 495 | expect(liElements[2].innerHTML).toEqual("Part-of-Speech"); |
| 496 | expect(menu.shownItem(2).active()).toBe(true); |
| 497 | expect(liElements[3]).toBe(undefined); |
| 498 | expect(menu.container().items[0].active()).toBe(false); |
| 499 | expect(menu.container().items[1].active()).toBe(false); |
| 500 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 501 | |
| 502 | // Activate next (4) |
| 503 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 504 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 505 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 506 | expect(menu.shownItem(0).active()).toBe(false); |
| 507 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 508 | expect(menu.shownItem(1).active()).toBe(false); |
| 509 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 510 | expect(menu.shownItem(2).active()).toBe(true); |
| 511 | expect(liElements[3]).toBe(undefined); |
| 512 | expect(menu.container().items[0].active()).toBe(false); |
| 513 | expect(menu.container().items[1].active()).toBe(false); |
| 514 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 515 | |
| 516 | // Activate next (4.1) - Jump to container part |
| 517 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 518 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 519 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 520 | expect(menu.shownItem(0).active()).toBe(false); |
| 521 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 522 | expect(menu.shownItem(1).active()).toBe(false); |
| 523 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 524 | expect(menu.shownItem(2).active()).toBe(false); |
| 525 | expect(liElements[3]).toBe(undefined); |
| 526 | expect(menu.container().items[0].active()).toBe(true); |
| 527 | expect(menu.container().items[1].active()).toBe(false); |
| 528 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 529 | |
| 530 | // Activate next (4.2) |
| 531 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 532 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 533 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 534 | expect(menu.shownItem(0).active()).toBe(false); |
| 535 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 536 | expect(menu.shownItem(1).active()).toBe(false); |
| 537 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 538 | expect(menu.shownItem(2).active()).toBe(false); |
| 539 | expect(liElements[3]).toBe(undefined); |
| 540 | expect(menu.container().items[0].active()).toBe(false); |
| 541 | expect(menu.container().items[1].active()).toBe(true); |
| 542 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 543 | |
| 544 | /** Prefix is not set |
| 545 | // Activate next (4.3) |
| 546 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 547 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 548 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 549 | expect(menu.shownItem(0).active()).toBe(false); |
| 550 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 551 | expect(menu.shownItem(1).active()).toBe(false); |
| 552 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 553 | expect(menu.shownItem(2).active()).toBe(true); |
| 554 | expect(liElements[3]).toBe(undefined); |
| 555 | expect(menu.container().items[0].active()).toBe(false); |
| 556 | expect(menu.container().items[1].active()).toBe(false); |
| 557 | expect(menu.container().items[2].active()).toBe(true); //prefix |
| 558 | */ |
| 559 | |
| 560 | // Activate next (5) - ROLL |
| 561 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 562 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 563 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 564 | expect(menu.shownItem(0).active()).toBe(true); |
| 565 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 566 | expect(menu.shownItem(1).active()).toBe(false); |
| 567 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 568 | expect(menu.shownItem(2).active()).toBe(false); |
| 569 | expect(liElements[3]).toBe(undefined); |
| 570 | expect(menu.container().items[0].active()).toBe(false); |
| 571 | expect(menu.container().items[1].active()).toBe(false); |
| 572 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 573 | |
| 574 | // Active next (6) |
| 575 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 576 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 577 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 578 | expect(menu.shownItem(0).active()).toBe(false); |
| 579 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 580 | expect(menu.shownItem(1).active()).toBe(true); |
| 581 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 582 | expect(menu.shownItem(2).active()).toBe(false); |
| 583 | expect(liElements[3]).toBe(undefined); |
| 584 | expect(menu.container().items[0].active()).toBe(false); |
| 585 | expect(menu.container().items[1].active()).toBe(false); |
| 586 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 587 | }); |
| 588 | |
| 589 | it('should be nextable without active field', function () { |
| 590 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 591 | menu.limit(3); |
| 592 | expect(menu.show()).toBe(true); |
| 593 | menu.next(); |
| 594 | expect(menu.shownItem(0).active()).toEqual(true); |
| 595 | }); |
| 596 | |
| 597 | |
| 598 | it('should be prevable', function () { |
| 599 | var menu = OwnContainerMenu.create(list); |
| 600 | menu._firstActive = true; |
| 601 | menu.limit(3); |
| 602 | expect(menu.show()).toBe(true); |
| 603 | |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 604 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 605 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 606 | expect(menu.shownItem(0).active()).toBe(true); |
| 607 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 608 | expect(menu.shownItem(1).active()).toBe(false); |
| 609 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 610 | expect(menu.shownItem(2).active()).toBe(false); |
| 611 | expect(liElements[3]).toBe(undefined); |
| 612 | |
| 613 | // Activate prev (1) - roll to bottom |
| 614 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 615 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 616 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 617 | expect(menu.shownItem(0).active()).toBe(false); |
| 618 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 619 | expect(menu.shownItem(1).active()).toBe(false); |
| 620 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 621 | expect(menu.shownItem(2).active()).toBe(true); |
| 622 | expect(liElements[3]).toBe(undefined); |
| 623 | |
| 624 | // Activate prev (2) |
| 625 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 626 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 627 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 628 | expect(menu.shownItem(0).active()).toBe(false); |
| 629 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 630 | expect(menu.shownItem(1).active()).toBe(true); |
| 631 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 632 | expect(menu.shownItem(2).active()).toBe(false); |
| 633 | expect(liElements[3]).toBe(undefined); |
| 634 | |
| 635 | // Activate prev (3) |
| 636 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 637 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 638 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 639 | expect(menu.shownItem(0).active()).toBe(true); |
| 640 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 641 | expect(menu.shownItem(1).active()).toBe(false); |
| 642 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 643 | expect(menu.shownItem(2).active()).toBe(false); |
| 644 | expect(liElements[3]).toBe(undefined); |
| 645 | |
| 646 | // Activate prev (4) |
| 647 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 648 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 649 | expect(liElements[0].innerHTML).toEqual("Lemma"); |
| 650 | expect(menu.shownItem(0).active()).toBe(true); |
| 651 | expect(liElements[1].innerHTML).toEqual("Morphology"); |
| 652 | expect(menu.shownItem(1).active()).toBe(false); |
| 653 | expect(liElements[2].innerHTML).toEqual("Part-of-Speech"); |
| 654 | expect(menu.shownItem(2).active()).toBe(false); |
| 655 | expect(liElements[3]).toBe(undefined); |
| 656 | |
| 657 | // Activate prev (5) |
| 658 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 659 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 660 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 661 | expect(menu.shownItem(0).active()).toBe(true); |
| 662 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 663 | expect(menu.shownItem(1).active()).toBe(false); |
| 664 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 665 | expect(menu.shownItem(2).active()).toBe(false); |
| 666 | expect(liElements[3]).toBe(undefined); |
| 667 | |
| 668 | // Activate next (1) |
| 669 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 670 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 671 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 672 | expect(menu.shownItem(0).active()).toBe(false); |
| 673 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 674 | expect(menu.shownItem(1).active()).toBe(true); |
| 675 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 676 | expect(menu.shownItem(2).active()).toBe(false); |
| 677 | expect(liElements[3]).toBe(undefined); |
| 678 | |
| 679 | // Activate prev (6) |
| 680 | menu.prev(); |
| 681 | |
| 682 | // Activate prev (7) |
| 683 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 684 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 685 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 686 | expect(menu.shownItem(0).active()).toBe(false); |
| 687 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 688 | expect(menu.shownItem(1).active()).toBe(false); |
| 689 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 690 | expect(menu.shownItem(2).active()).toBe(true); |
| 691 | expect(liElements[3]).toBe(undefined); |
| 692 | }); |
| 693 | |
| 694 | it('should be prevable with containerItems', function () { |
| 695 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 696 | menu._firstActive = true; |
| 697 | menu.limit(3); |
| 698 | expect(menu.show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 699 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 700 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 701 | expect(menu.shownItem(0).active()).toBe(true); |
| 702 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 703 | expect(menu.shownItem(1).active()).toBe(false); |
| 704 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 705 | expect(menu.shownItem(2).active()).toBe(false); |
| 706 | expect(liElements[3]).toBe(undefined); |
| 707 | expect(menu.container().items[0].active()).toBe(false); |
| 708 | expect(menu.container().items[1].active()).toBe(false); |
| 709 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 710 | |
| 711 | // Activate prev (1) - roll to bottom - base items stay, now container |
| 712 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 713 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 714 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 715 | expect(menu.shownItem(0).active()).toBe(false); |
| 716 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 717 | expect(menu.shownItem(1).active()).toBe(false); |
| 718 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 719 | expect(menu.shownItem(2).active()).toBe(false); |
| 720 | expect(liElements[3]).toBe(undefined); |
| 721 | expect(menu.container().items[0].active()).toBe(false); |
| 722 | expect(menu.container().items[1].active()).toBe(true); |
| 723 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 724 | |
| 725 | // Activate prev(2) - next container item |
| 726 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 727 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 728 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 729 | expect(menu.shownItem(0).active()).toBe(false); |
| 730 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 731 | expect(menu.shownItem(1).active()).toBe(false); |
| 732 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 733 | expect(menu.shownItem(2).active()).toBe(false); |
| 734 | expect(liElements[3]).toBe(undefined); |
| 735 | expect(menu.container().items[0].active()).toBe(true); |
| 736 | expect(menu.container().items[1].active()).toBe(false); |
| 737 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 738 | |
| 739 | // Activate prev (3) - roll to bottom of normal list |
| 740 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 741 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 742 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 743 | expect(menu.shownItem(0).active()).toBe(false); |
| 744 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 745 | expect(menu.shownItem(1).active()).toBe(false); |
| 746 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 747 | expect(menu.shownItem(2).active()).toBe(true); |
| 748 | expect(liElements[3]).toBe(undefined); |
| 749 | expect(menu.container().items[0].active()).toBe(false); |
| 750 | expect(menu.container().items[1].active()).toBe(false); |
| 751 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 752 | |
| 753 | // Activate prev (4) |
| 754 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 755 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 756 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 757 | expect(menu.shownItem(0).active()).toBe(false); |
| 758 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 759 | expect(menu.shownItem(1).active()).toBe(true); |
| 760 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 761 | expect(menu.shownItem(2).active()).toBe(false); |
| 762 | expect(liElements[3]).toBe(undefined); |
| 763 | expect(menu.container().items[0].active()).toBe(false); |
| 764 | expect(menu.container().items[1].active()).toBe(false); |
| 765 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 766 | |
| 767 | // Activate prev (5) |
| 768 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 769 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 770 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 771 | expect(menu.shownItem(0).active()).toBe(true); |
| 772 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 773 | expect(menu.shownItem(1).active()).toBe(false); |
| 774 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 775 | expect(menu.shownItem(2).active()).toBe(false); |
| 776 | expect(liElements[3]).toBe(undefined); |
| 777 | expect(menu.container().items[0].active()).toBe(false); |
| 778 | expect(menu.container().items[1].active()).toBe(false); |
| 779 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 780 | |
| 781 | // Activate prev (6) |
| 782 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 783 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 784 | expect(liElements[0].innerHTML).toEqual("Lemma"); |
| 785 | expect(menu.shownItem(0).active()).toBe(true); |
| 786 | expect(liElements[1].innerHTML).toEqual("Morphology"); |
| 787 | expect(menu.shownItem(1).active()).toBe(false); |
| 788 | expect(liElements[2].innerHTML).toEqual("Part-of-Speech"); |
| 789 | expect(menu.shownItem(2).active()).toBe(false); |
| 790 | expect(liElements[3]).toBe(undefined); |
| 791 | expect(menu.container().items[0].active()).toBe(false); |
| 792 | expect(menu.container().items[1].active()).toBe(false); |
| 793 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 794 | |
| 795 | // Activate prev (7) |
| 796 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 797 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 798 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 799 | expect(menu.shownItem(0).active()).toBe(true); |
| 800 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 801 | expect(menu.shownItem(1).active()).toBe(false); |
| 802 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 803 | expect(menu.shownItem(2).active()).toBe(false); |
| 804 | expect(liElements[3]).toBe(undefined); |
| 805 | expect(menu.container().items[0].active()).toBe(false); |
| 806 | expect(menu.container().items[1].active()).toBe(false); |
| 807 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 808 | |
| 809 | // Activate next (8) |
| 810 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 811 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 812 | expect(liElements[0].innerHTML).toEqual("Constituency"); |
| 813 | expect(menu.shownItem(0).active()).toBe(false); |
| 814 | expect(liElements[1].innerHTML).toEqual("Lemma"); |
| 815 | expect(menu.shownItem(1).active()).toBe(true); |
| 816 | expect(liElements[2].innerHTML).toEqual("Morphology"); |
| 817 | expect(menu.shownItem(2).active()).toBe(false); |
| 818 | expect(liElements[3]).toBe(undefined); |
| 819 | expect(menu.container().items[0].active()).toBe(false); |
| 820 | expect(menu.container().items[1].active()).toBe(false); |
| 821 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 822 | |
| 823 | // Activate prev (9) |
| 824 | menu.prev(); |
| 825 | menu.prev(); |
| 826 | menu.prev(); |
| 827 | |
| 828 | // Activate prev (10) |
| 829 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 830 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 831 | expect(liElements[0].innerHTML).toEqual("Morphology"); |
| 832 | expect(menu.shownItem(0).active()).toBe(false); |
| 833 | expect(liElements[1].innerHTML).toEqual("Part-of-Speech"); |
| 834 | expect(menu.shownItem(1).active()).toBe(false); |
| 835 | expect(liElements[2].innerHTML).toEqual("Syntax"); |
| 836 | expect(menu.shownItem(2).active()).toBe(true); |
| 837 | expect(liElements[3]).toBe(undefined); |
| 838 | expect(menu.container().items[0].active()).toBe(false); |
| 839 | expect(menu.container().items[1].active()).toBe(false); |
| 840 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 841 | }); |
| 842 | |
| 843 | it('should be prevable without active field', function () { |
| 844 | var menu = OwnContainerMenu.create(list); |
| 845 | menu.limit(3); |
| 846 | expect(menu.show()).toBe(true); |
| 847 | menu.prev(); |
| 848 | expect(menu.shownItem(2).active()).toEqual(true); |
| 849 | expect(menu.shownItem(2).lcField()).toEqual(' syntax'); |
| 850 | }); |
| 851 | |
| 852 | it('should be navigatable and filterable (prefix = "o")', function () { |
| 853 | var menu = OwnContainerMenu.create(list); |
| 854 | menu._firstActive = true; |
| 855 | menu.limit(2); |
| 856 | |
| 857 | expect(menu.prefix("o").show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 858 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 859 | expect(liElements[0].innerHTML).toEqual("C<mark>o</mark>nstituency"); |
| 860 | expect(menu.shownItem(0).active()).toBe(true); |
| 861 | expect(liElements[1].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 862 | expect(menu.shownItem(1).active()).toBe(false); |
| 863 | expect(menu.shownItem(2)).toBe(undefined); |
| 864 | |
| 865 | // Next (1) |
| 866 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 867 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 868 | expect(liElements[0].innerHTML).toEqual("C<mark>o</mark>nstituency"); |
| 869 | expect(menu.shownItem(0).active()).toBe(false); |
| 870 | expect(liElements[1].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 871 | expect(menu.shownItem(1).active()).toBe(true); |
| 872 | expect(menu.shownItem(2)).toBe(undefined); |
| 873 | |
| 874 | // Next (2) |
| 875 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 876 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 877 | expect(liElements[0].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 878 | expect(menu.shownItem(0).active()).toBe(false); |
| 879 | expect(liElements[1].innerHTML).toEqual("Part-<mark>o</mark>f-Speech"); |
| 880 | expect(menu.shownItem(1).active()).toBe(true); |
| 881 | expect(menu.shownItem(2)).toBe(undefined); |
| 882 | |
| 883 | // Next (3) - to prefix |
| 884 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 885 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 886 | expect(liElements[0].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 887 | expect(menu.shownItem(0).active()).toBe(false); |
| 888 | expect(liElements[1].innerHTML).toEqual("Part-<mark>o</mark>f-Speech"); |
| 889 | expect(menu.shownItem(1).active()).toBe(false); |
| 890 | expect(menu.shownItem(2)).toBe(undefined); |
| 891 | |
| 892 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 893 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 894 | expect(liElements[0].innerHTML).toEqual("C<mark>o</mark>nstituency"); |
| 895 | expect(menu.shownItem(0).active()).toBe(true); |
| 896 | expect(liElements[1].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 897 | expect(menu.shownItem(1).active()).toBe(false); |
| 898 | expect(menu.shownItem(2)).toBe(undefined); |
| 899 | }); |
| 900 | |
| 901 | it('should be navigatable and filterable (prefix = "o") using containerItems', function () { |
| 902 | var menu = OwnContainerMenu.create(list,ExampleItemList); |
| 903 | menu._firstActive = true; |
| 904 | menu.limit(2); |
| 905 | |
| 906 | expect(menu.prefix("o").show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 907 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 908 | expect(liElements[0].innerHTML).toEqual("C<mark>o</mark>nstituency"); |
| 909 | expect(menu.shownItem(0).active()).toBe(true); |
| 910 | expect(liElements[1].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 911 | expect(menu.shownItem(1).active()).toBe(false); |
| 912 | expect(menu.shownItem(2)).toBe(undefined); |
| 913 | expect(menu.container().items[0].active()).toBe(false); |
| 914 | expect(menu.container().items[1].active()).toBe(false); |
| 915 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 916 | |
| 917 | // Next (1) |
| 918 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 919 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 920 | expect(liElements[0].innerHTML).toEqual("C<mark>o</mark>nstituency"); |
| 921 | expect(menu.shownItem(0).active()).toBe(false); |
| 922 | expect(liElements[1].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 923 | expect(menu.shownItem(1).active()).toBe(true); |
| 924 | expect(menu.shownItem(2)).toBe(undefined); |
| 925 | expect(menu.container().items[0].active()).toBe(false); |
| 926 | expect(menu.container().items[1].active()).toBe(false); |
| 927 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 928 | |
| 929 | // Next (2) |
| 930 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 931 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 932 | expect(liElements[0].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 933 | expect(menu.shownItem(0).active()).toBe(false); |
| 934 | expect(liElements[1].innerHTML).toEqual("Part-<mark>o</mark>f-Speech"); |
| 935 | expect(menu.shownItem(1).active()).toBe(true); |
| 936 | expect(menu.shownItem(2)).toBe(undefined); |
| 937 | expect(menu.container().items[0].active()).toBe(false); |
| 938 | expect(menu.container().items[1].active()).toBe(false); |
| 939 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 940 | |
| 941 | // Next (3) - to first container Item |
| 942 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 943 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 944 | expect(liElements[0].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 945 | expect(menu.shownItem(0).active()).toBe(false); |
| 946 | expect(liElements[1].innerHTML).toEqual("Part-<mark>o</mark>f-Speech"); |
| 947 | expect(menu.shownItem(1).active()).toBe(false); |
| 948 | expect(menu.shownItem(2)).toBe(undefined); |
| 949 | expect(menu.container().items[0].active()).toBe(true); |
| 950 | expect(menu.container().items[1].active()).toBe(false); |
| 951 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 952 | |
| 953 | // Next (4) - to second container Item |
| 954 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 955 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 956 | expect(liElements[0].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 957 | expect(menu.shownItem(0).active()).toBe(false); |
| 958 | expect(liElements[1].innerHTML).toEqual("Part-<mark>o</mark>f-Speech"); |
| 959 | expect(menu.shownItem(1).active()).toBe(false); |
| 960 | expect(menu.shownItem(2)).toBe(undefined); |
| 961 | expect(menu.container().items[0].active()).toBe(false); |
| 962 | expect(menu.container().items[1].active()).toBe(true); |
| 963 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 964 | |
| 965 | // Next (5) - to prefix |
| 966 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 967 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 968 | expect(liElements[0].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 969 | expect(menu.shownItem(0).active()).toBe(false); |
| 970 | expect(liElements[1].innerHTML).toEqual("Part-<mark>o</mark>f-Speech"); |
| 971 | expect(menu.shownItem(1).active()).toBe(false); |
| 972 | expect(menu.shownItem(2)).toBe(undefined); |
| 973 | expect(menu.container().items[0].active()).toBe(false); |
| 974 | expect(menu.container().items[1].active()).toBe(false); |
| 975 | expect(menu.container().items[2].active()).toBe(true); //prefix |
| 976 | |
| 977 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 978 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 979 | expect(liElements[0].innerHTML).toEqual("C<mark>o</mark>nstituency"); |
| 980 | expect(menu.shownItem(0).active()).toBe(true); |
| 981 | expect(liElements[1].innerHTML).toEqual("M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy"); |
| 982 | expect(menu.shownItem(1).active()).toBe(false); |
| 983 | expect(menu.shownItem(2)).toBe(undefined); |
| 984 | expect(menu.container().items[0].active()).toBe(false); |
| 985 | expect(menu.container().items[1].active()).toBe(false); |
| 986 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 987 | }); |
| 988 | |
| 989 | it('should be navigatable and filterable (prefix = "ex", "e") with containerItems', function () { |
| 990 | var menu = OwnContainerMenu.create(listWithEX,ExampleItemList); |
| 991 | menu._firstActive = true; |
| 992 | menu.limit(3); |
| 993 | |
| 994 | expect(menu.prefix("ex").show()).toBe(true); |
| 995 | expect(menu.prefix()).toEqual('ex'); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 996 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 997 | expect(liElements[0].innerHTML).toEqual("<mark>ex</mark>ample 1 Constituency"); |
| 998 | expect(menu.shownItem(0).active()).toBe(true); |
| 999 | expect(liElements[1].innerHTML).toEqual("<mark>ex</mark>ample 2 Morphology"); |
| 1000 | expect(menu.shownItem(1).active()).toBe(false); |
| 1001 | expect(menu.shownItem(3)).toBe(undefined); |
| 1002 | expect(menu.container().items[0].active()).toBe(false); |
| 1003 | expect(menu.container().items[1].active()).toBe(false); |
| 1004 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1005 | |
| 1006 | // Next (1) |
| 1007 | menu.next(); |
| 1008 | expect(menu.prefix()).toEqual('ex'); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1009 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1010 | expect(liElements[0].innerHTML).toEqual("<mark>ex</mark>ample 1 Constituency"); |
| 1011 | expect(menu.shownItem(0).active()).toBe(false); |
| 1012 | expect(liElements[1].innerHTML).toEqual("<mark>ex</mark>ample 2 Morphology"); |
| 1013 | expect(menu.shownItem(1).active()).toBe(true); |
| 1014 | expect(menu.shownItem(3)).toBe(undefined); |
| 1015 | expect(menu.container().items[0].active()).toBe(false); |
| 1016 | expect(menu.container().items[1].active()).toBe(false); |
| 1017 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1018 | |
| 1019 | // Next (2) |
| 1020 | menu.next(); |
| 1021 | expect(menu.prefix()).toEqual('ex'); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1022 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1023 | expect(liElements[0].innerHTML).toEqual("<mark>ex</mark>ample 1 Constituency"); |
| 1024 | expect(menu.shownItem(0).active()).toBe(false); |
| 1025 | expect(liElements[1].innerHTML).toEqual("<mark>ex</mark>ample 2 Morphology"); |
| 1026 | expect(menu.shownItem(1).active()).toBe(false); |
| 1027 | expect(menu.shownItem(3)).toBe(undefined); |
| 1028 | expect(menu.container().items[0].active()).toBe(true); |
| 1029 | expect(menu.container().items[1].active()).toBe(false); |
| 1030 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1031 | |
| 1032 | //Roll to Prefix |
| 1033 | menu.next(); |
| 1034 | menu.next(); |
| 1035 | expect(menu.prefix()).toEqual('ex'); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1036 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1037 | expect(liElements[0].innerHTML).toEqual("<mark>ex</mark>ample 1 Constituency"); |
| 1038 | expect(menu.shownItem(0).active()).toBe(false); |
| 1039 | expect(liElements[1].innerHTML).toEqual("<mark>ex</mark>ample 2 Morphology"); |
| 1040 | expect(menu.shownItem(1).active()).toBe(false); |
| 1041 | expect(menu.shownItem(3)).toBe(undefined); |
| 1042 | expect(menu.container().items[0].active()).toBe(false); |
| 1043 | expect(menu.container().items[1].active()).toBe(false); |
| 1044 | expect(menu.container().items[2].active()).toBe(true); //prefix |
| 1045 | |
| 1046 | // Reset limit |
| 1047 | menu.limit(5); |
| 1048 | |
| 1049 | // Change show |
| 1050 | expect(menu.prefix("e").show()).toBe(true); |
| 1051 | expect(menu._prefix.active()).toBe(false); |
| 1052 | expect(menu.prefix()).toEqual('e'); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1053 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1054 | expect(liElements[0].innerHTML).toEqual("<mark>e</mark>xampl<mark>e</mark> 1 Constitu<mark>e</mark>ncy"); |
| 1055 | expect(menu.shownItem(0).active()).toBe(true); |
| 1056 | expect(liElements[1].innerHTML).toEqual("<mark>e</mark>xampl<mark>e</mark> 2 Morphology"); |
| 1057 | expect(menu.shownItem(1).active()).toBe(false); |
| 1058 | expect(menu.shownItem(3)).toBe(undefined); |
| 1059 | expect(menu.container().items[0].active()).toBe(false); |
| 1060 | expect(menu.container().items[1].active()).toBe(false); |
| 1061 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1062 | |
| 1063 | // Next (1) |
| 1064 | menu.next(); |
| 1065 | expect(menu._prefix.active()).toBe(false); |
| 1066 | expect(menu.prefix()).toEqual('e'); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1067 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1068 | expect(liElements[0].innerHTML).toEqual("<mark>e</mark>xampl<mark>e</mark> 1 Constitu<mark>e</mark>ncy"); |
| 1069 | expect(menu.shownItem(0).active()).toBe(false); |
| 1070 | expect(liElements[1].innerHTML).toEqual("<mark>e</mark>xampl<mark>e</mark> 2 Morphology"); |
| 1071 | expect(menu.shownItem(1).active()).toBe(true); |
| 1072 | expect(menu.shownItem(3)).toBe(undefined); |
| 1073 | expect(menu.container().items[0].active()).toBe(false); |
| 1074 | expect(menu.container().items[1].active()).toBe(false); |
| 1075 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1076 | |
| 1077 | // Next (2) |
| 1078 | menu.next(); |
| 1079 | expect(menu._prefix.active()).toBe(false); |
| 1080 | expect(menu.prefix()).toEqual('e'); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1081 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1082 | expect(liElements[0].innerHTML).toEqual("<mark>e</mark>xampl<mark>e</mark> 1 Constitu<mark>e</mark>ncy"); |
| 1083 | expect(menu.shownItem(0).active()).toBe(false); |
| 1084 | expect(liElements[1].innerHTML).toEqual("<mark>e</mark>xampl<mark>e</mark> 2 Morphology"); |
| 1085 | expect(menu.shownItem(1).active()).toBe(false); |
| 1086 | expect(menu.shownItem(3)).toBe(undefined); |
| 1087 | expect(menu.container().items[0].active()).toBe(true); |
| 1088 | expect(menu.container().items[1].active()).toBe(false); |
| 1089 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1090 | |
| 1091 | |
| 1092 | // Next (3) |
| 1093 | menu.next(); |
| 1094 | menu.next(); |
| 1095 | expect(menu._prefix.active()).toBe(true); |
| 1096 | expect(menu.prefix()).toEqual('e'); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1097 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1098 | expect(liElements[0].innerHTML).toEqual("<mark>e</mark>xampl<mark>e</mark> 1 Constitu<mark>e</mark>ncy"); |
| 1099 | expect(menu.shownItem(0).active()).toBe(false); |
| 1100 | expect(liElements[1].innerHTML).toEqual("<mark>e</mark>xampl<mark>e</mark> 2 Morphology"); |
| 1101 | expect(menu.shownItem(1).active()).toBe(false); |
| 1102 | expect(menu.shownItem(3)).toBe(undefined); |
| 1103 | expect(menu.container().items[0].active()).toBe(false); |
| 1104 | expect(menu.container().items[1].active()).toBe(false); |
| 1105 | expect(menu.container().items[2].active()).toBe(true); //prefix |
| 1106 | }); |
| 1107 | |
| 1108 | |
| 1109 | it('should be filterable (multiple prefix = "pro sin")', function () { |
| 1110 | var menu = OwnContainerMenu.create(listMultiPrefix); |
| 1111 | menu._firstActive = true; |
| 1112 | |
| 1113 | menu.limit(2); |
| 1114 | expect(menu.prefix("pro sin").show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1115 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1116 | expect(liElements[0].innerHTML).toEqual( |
| 1117 | "Personal <mark>Pro</mark>noun, <mark>Sin</mark>gular" |
| 1118 | ); |
| 1119 | |
| 1120 | expect(menu.shownItem(0).active()).toBe(true); |
| 1121 | expect(liElements[1].innerHTML).toEqual("Personal <mark>Pro</mark>noun, <mark>Sin</mark>gular, Accusative"); |
| 1122 | expect(menu.shownItem(1).active()).toBe(false); |
| 1123 | |
| 1124 | expect(menu.shownItem(2)).toBe(undefined); |
| 1125 | }); |
| 1126 | |
| 1127 | it('should be filterable (trimming = " p")', function () { |
| 1128 | var menu = OwnContainerMenu.create(listMultiPrefix); |
| 1129 | // menu._firstActive = true; |
| 1130 | |
| 1131 | menu.limit(2); |
| 1132 | expect(menu.show()).toBe(true); |
| 1133 | menu._prefix.add(" "); |
| 1134 | expect(menu.show()).toBe(true); |
| 1135 | menu._prefix.add("p") |
| 1136 | expect(menu.show()).toBe(true); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1137 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1138 | expect(liElements[0].innerHTML).toEqual("<mark>P</mark>ersonal <mark>P</mark>ronoun"); |
| 1139 | }); |
| 1140 | |
| 1141 | |
| 1142 | it('should choose prefix with failing prefix (1)', function () { |
| 1143 | var menu = OwnContainerMenu.create(list); |
| 1144 | menu.limit(2); |
| 1145 | expect(menu.prefix("exit").show()).toBe(true); |
| 1146 | expect(menu.element().querySelector('li')).toBe(null); |
| 1147 | expect(menu.shownItem(0)).toBeUndefined(); |
| 1148 | expect(menu._prefix.active()).toBe(true); |
| 1149 | }); |
| 1150 | |
| 1151 | |
| 1152 | it('should choose prefix with failing prefix (2)', function () { |
| 1153 | var menu = OwnContainerMenu.create(list); |
| 1154 | menu.limit(2); |
| 1155 | expect(menu.show()).toBe(true); |
| 1156 | expect(menu.prefix("exit").show()).toBe(true); |
| 1157 | expect(menu.element().querySelector('li')).toBe(null); |
| 1158 | expect(menu.shownItem(0)).toBeUndefined(); |
| 1159 | expect(menu._prefix.active()).toBe(true); |
| 1160 | }); |
| 1161 | |
| 1162 | it('should ignore navigation with failing prefix', function () { |
| 1163 | var menu = OwnContainerMenu.create(list); |
| 1164 | menu.limit(2); |
| 1165 | expect(menu.show()).toBe(true); |
| 1166 | |
| 1167 | menu.next(); |
| 1168 | |
| 1169 | expect(menu.prefix("exit").show()).toBe(true); |
| 1170 | expect(menu.element().querySelector('li')).toBe(null); |
| 1171 | expect(menu.shownItem(0)).toBeUndefined(); |
| 1172 | expect(menu._prefix.active()).toBe(true); |
| 1173 | |
| 1174 | menu.next(); |
| 1175 | expect(menu._prefix.active()).toBe(true); |
| 1176 | |
| 1177 | menu.prev(); |
| 1178 | expect(menu._prefix.active()).toBe(true); |
| 1179 | |
| 1180 | }); |
| 1181 | |
| 1182 | it('should be navigatable with prefix', function () { |
| 1183 | var menu = OwnContainerMenu.create(demolist); |
| 1184 | menu._firstActive = true; |
| 1185 | |
| 1186 | menu.limit(3); |
| 1187 | |
| 1188 | expect(menu.show()).toBe(true); |
| 1189 | expect(menu.prefix()).toEqual(""); |
| 1190 | |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1191 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1192 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1193 | expect(menu.shownItem(0).active()).toBe(true); |
| 1194 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1195 | expect(menu.shownItem(1).active()).toBe(false); |
| 1196 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1197 | expect(menu.shownItem(2).active()).toBe(false); |
| 1198 | expect(menu.shownItem(3)).toBe(undefined); |
| 1199 | |
| 1200 | menu._prefix.add('a'); |
| 1201 | expect(menu.show()).toBe(true); |
| 1202 | expect(menu.prefix()).toEqual("a"); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1203 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1204 | expect(liElements[0].innerHTML).toEqual("<mark>A</mark>utor"); |
| 1205 | |
| 1206 | menu._prefix.add('u'); |
| 1207 | expect(menu.show()).toBe(true); |
| 1208 | expect(menu.prefix()).toEqual("au"); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1209 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1210 | expect(liElements[0].innerHTML).toEqual("<mark>Au</mark>tor"); |
| 1211 | |
| 1212 | menu._prefix.chop(); |
| 1213 | expect(menu.show()).toBe(true); |
| 1214 | expect(menu.prefix()).toEqual("a"); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1215 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1216 | expect(liElements[0].innerHTML).toEqual("<mark>A</mark>utor"); |
| 1217 | |
| 1218 | menu._prefix.chop(); |
| 1219 | expect(menu.show()).toBe(true); |
| 1220 | expect(menu.prefix()).toEqual(""); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1221 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1222 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1223 | expect(menu.shownItem(0).active()).toBe(true); |
| 1224 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1225 | expect(menu.shownItem(1).active()).toBe(false); |
| 1226 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1227 | expect(menu.shownItem(2).active()).toBe(false); |
| 1228 | expect(menu.shownItem(3)).toBe(undefined); |
| 1229 | |
| 1230 | // Forward |
| 1231 | menu._prefix.chop(); |
| 1232 | expect(menu.show()).toBe(true); |
| 1233 | expect(menu.prefix()).toEqual(""); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1234 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1235 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1236 | expect(menu.shownItem(0).active()).toBe(true); |
| 1237 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1238 | expect(menu.shownItem(1).active()).toBe(false); |
| 1239 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1240 | expect(menu.shownItem(2).active()).toBe(false); |
| 1241 | |
| 1242 | // Forward |
| 1243 | menu.next(); |
| 1244 | expect(menu.prefix()).toEqual(""); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1245 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1246 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1247 | expect(menu.shownItem(0).active()).toBe(false); |
| 1248 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1249 | expect(menu.shownItem(1).active()).toBe(true); |
| 1250 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1251 | expect(menu.shownItem(2).active()).toBe(false); |
| 1252 | expect(menu.shownItem(3)).toBe(undefined); |
| 1253 | |
| 1254 | // Forward |
| 1255 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1256 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1257 | expect(menu.prefix()).toEqual(""); |
| 1258 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1259 | expect(menu.shownItem(0).active()).toBe(false); |
| 1260 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1261 | expect(menu.shownItem(1).active()).toBe(false); |
| 1262 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1263 | expect(menu.shownItem(2).active()).toBe(true); |
| 1264 | expect(menu.shownItem(3)).toBe(undefined); |
| 1265 | |
| 1266 | // Forward |
| 1267 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1268 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1269 | expect(menu.prefix()).toEqual(""); |
| 1270 | expect(liElements[0].innerHTML).toEqual("Untertitel"); |
| 1271 | expect(menu.shownItem(0).active()).toBe(false); |
| 1272 | expect(liElements[1].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1273 | expect(menu.shownItem(1).active()).toBe(false); |
| 1274 | expect(liElements[2].innerHTML).toEqual("Länge"); |
| 1275 | expect(menu.shownItem(2).active()).toBe(true); |
| 1276 | expect(menu.shownItem(3)).toBe(undefined); |
| 1277 | |
| 1278 | // Forward |
| 1279 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1280 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1281 | expect(menu.prefix()).toEqual(""); |
| 1282 | expect(liElements[0].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1283 | expect(menu.shownItem(0).active()).toBe(false); |
| 1284 | expect(liElements[1].innerHTML).toEqual("Länge"); |
| 1285 | expect(menu.shownItem(1).active()).toBe(false); |
| 1286 | expect(liElements[2].innerHTML).toEqual("Autor"); |
| 1287 | expect(menu.shownItem(2).active()).toBe(true); |
| 1288 | expect(menu.shownItem(3)).toBe(undefined); |
| 1289 | |
| 1290 | // Forward |
| 1291 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1292 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1293 | expect(menu.prefix()).toEqual(""); |
| 1294 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1295 | expect(menu.shownItem(0).active()).toBe(true); |
| 1296 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1297 | expect(menu.shownItem(1).active()).toBe(false); |
| 1298 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1299 | expect(menu.shownItem(2).active()).toBe(false); |
| 1300 | }); |
| 1301 | |
| 1302 | it('should be navigatable with prefix and containerItems', function () { |
| 1303 | var menu = OwnContainerMenu.create(demolist,ExampleItemList); |
| 1304 | menu._firstActive = true; |
| 1305 | |
| 1306 | menu.limit(3); |
| 1307 | |
| 1308 | expect(menu.show()).toBe(true); |
| 1309 | expect(menu.prefix()).toEqual(""); |
| 1310 | |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1311 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1312 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1313 | expect(menu.shownItem(0).active()).toBe(true); |
| 1314 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1315 | expect(menu.shownItem(1).active()).toBe(false); |
| 1316 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1317 | expect(menu.shownItem(2).active()).toBe(false); |
| 1318 | expect(menu.shownItem(3)).toBe(undefined); |
| 1319 | expect(menu.container().items[0].active()).toBe(false); |
| 1320 | expect(menu.container().items[1].active()).toBe(false); |
| 1321 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1322 | |
| 1323 | menu._prefix.add('a'); |
| 1324 | expect(menu.show()).toBe(true); |
| 1325 | expect(menu.prefix()).toEqual("a"); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1326 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1327 | expect(liElements[0].innerHTML).toEqual("<mark>A</mark>utor"); |
| 1328 | expect(menu.container().items[0].active()).toBe(false); |
| 1329 | expect(menu.container().items[1].active()).toBe(false); |
| 1330 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1331 | |
| 1332 | menu._prefix.add('u'); |
| 1333 | expect(menu.show()).toBe(true); |
| 1334 | expect(menu.prefix()).toEqual("au"); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1335 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1336 | expect(liElements[0].innerHTML).toEqual("<mark>Au</mark>tor"); |
| 1337 | expect(menu.container().items[0].active()).toBe(false); |
| 1338 | expect(menu.container().items[1].active()).toBe(false); |
| 1339 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1340 | |
| 1341 | menu._prefix.chop(); |
| 1342 | expect(menu.show()).toBe(true); |
| 1343 | expect(menu.prefix()).toEqual("a"); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1344 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1345 | expect(liElements[0].innerHTML).toEqual("<mark>A</mark>utor"); |
| 1346 | expect(menu.container().items[0].active()).toBe(false); |
| 1347 | expect(menu.container().items[1].active()).toBe(false); |
| 1348 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1349 | |
| 1350 | menu._prefix.chop(); |
| 1351 | expect(menu.show()).toBe(true); |
| 1352 | expect(menu.prefix()).toEqual(""); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1353 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1354 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1355 | expect(menu.shownItem(0).active()).toBe(true); |
| 1356 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1357 | expect(menu.shownItem(1).active()).toBe(false); |
| 1358 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1359 | expect(menu.shownItem(2).active()).toBe(false); |
| 1360 | expect(menu.shownItem(3)).toBe(undefined); |
| 1361 | expect(menu.container().items[0].active()).toBe(false); |
| 1362 | expect(menu.container().items[1].active()).toBe(false); |
| 1363 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1364 | |
| 1365 | // Forward |
| 1366 | menu._prefix.chop(); |
| 1367 | expect(menu.show()).toBe(true); |
| 1368 | expect(menu.prefix()).toEqual(""); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1369 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1370 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1371 | expect(menu.shownItem(0).active()).toBe(true); |
| 1372 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1373 | expect(menu.shownItem(1).active()).toBe(false); |
| 1374 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1375 | expect(menu.shownItem(2).active()).toBe(false); |
| 1376 | expect(menu.container().items[0].active()).toBe(false); |
| 1377 | expect(menu.container().items[1].active()).toBe(false); |
| 1378 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1379 | |
| 1380 | // Forward |
| 1381 | menu.next(); |
| 1382 | expect(menu.prefix()).toEqual(""); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1383 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1384 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1385 | expect(menu.shownItem(0).active()).toBe(false); |
| 1386 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1387 | expect(menu.shownItem(1).active()).toBe(true); |
| 1388 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1389 | expect(menu.shownItem(2).active()).toBe(false); |
| 1390 | expect(menu.shownItem(3)).toBe(undefined); |
| 1391 | expect(menu.container().items[0].active()).toBe(false); |
| 1392 | expect(menu.container().items[1].active()).toBe(false); |
| 1393 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1394 | |
| 1395 | // Forward |
| 1396 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1397 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1398 | expect(menu.prefix()).toEqual(""); |
| 1399 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1400 | expect(menu.shownItem(0).active()).toBe(false); |
| 1401 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1402 | expect(menu.shownItem(1).active()).toBe(false); |
| 1403 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1404 | expect(menu.shownItem(2).active()).toBe(true); |
| 1405 | expect(menu.shownItem(3)).toBe(undefined); |
| 1406 | expect(menu.container().items[0].active()).toBe(false); |
| 1407 | expect(menu.container().items[1].active()).toBe(false); |
| 1408 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1409 | |
| 1410 | // Forward |
| 1411 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1412 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1413 | expect(menu.prefix()).toEqual(""); |
| 1414 | expect(liElements[0].innerHTML).toEqual("Untertitel"); |
| 1415 | expect(menu.shownItem(0).active()).toBe(false); |
| 1416 | expect(liElements[1].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1417 | expect(menu.shownItem(1).active()).toBe(false); |
| 1418 | expect(liElements[2].innerHTML).toEqual("Länge"); |
| 1419 | expect(menu.shownItem(2).active()).toBe(true); |
| 1420 | expect(menu.shownItem(3)).toBe(undefined); |
| 1421 | expect(menu.container().items[0].active()).toBe(false); |
| 1422 | expect(menu.container().items[1].active()).toBe(false); |
| 1423 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1424 | |
| 1425 | // Forward |
| 1426 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1427 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1428 | expect(menu.prefix()).toEqual(""); |
| 1429 | expect(liElements[0].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1430 | expect(menu.shownItem(0).active()).toBe(false); |
| 1431 | expect(liElements[1].innerHTML).toEqual("Länge"); |
| 1432 | expect(menu.shownItem(1).active()).toBe(false); |
| 1433 | expect(liElements[2].innerHTML).toEqual("Autor"); |
| 1434 | expect(menu.shownItem(2).active()).toBe(true); |
| 1435 | expect(menu.shownItem(3)).toBe(undefined); |
| 1436 | expect(menu.container().items[0].active()).toBe(false); |
| 1437 | expect(menu.container().items[1].active()).toBe(false); |
| 1438 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1439 | |
| 1440 | // Forward |
| 1441 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1442 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1443 | expect(menu.prefix()).toEqual(""); |
| 1444 | expect(liElements[0].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1445 | expect(menu.shownItem(0).active()).toBe(false); |
| 1446 | expect(liElements[1].innerHTML).toEqual("Länge"); |
| 1447 | expect(menu.shownItem(1).active()).toBe(false); |
| 1448 | expect(liElements[2].innerHTML).toEqual("Autor"); |
| 1449 | expect(menu.shownItem(2).active()).toBe(false); |
| 1450 | expect(menu.shownItem(3)).toBe(undefined); |
| 1451 | expect(menu.container().items[0].active()).toBe(true); |
| 1452 | expect(menu.container().items[1].active()).toBe(false); |
| 1453 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1454 | |
| 1455 | // Forward |
| 1456 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1457 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1458 | expect(menu.prefix()).toEqual(""); |
| 1459 | expect(liElements[0].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1460 | expect(menu.shownItem(0).active()).toBe(false); |
| 1461 | expect(liElements[1].innerHTML).toEqual("Länge"); |
| 1462 | expect(menu.shownItem(1).active()).toBe(false); |
| 1463 | expect(liElements[2].innerHTML).toEqual("Autor"); |
| 1464 | expect(menu.shownItem(2).active()).toBe(false); |
| 1465 | expect(menu.shownItem(3)).toBe(undefined); |
| 1466 | expect(menu.container().items[0].active()).toBe(false); |
| 1467 | expect(menu.container().items[1].active()).toBe(true); |
| 1468 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1469 | |
| 1470 | // Forward |
| 1471 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1472 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1473 | expect(menu.prefix()).toEqual(""); |
| 1474 | expect(liElements[0].innerHTML).toEqual("Titel"); |
| 1475 | expect(menu.shownItem(0).active()).toBe(true); |
| 1476 | expect(liElements[1].innerHTML).toEqual("Untertitel"); |
| 1477 | expect(menu.shownItem(1).active()).toBe(false); |
| 1478 | expect(liElements[2].innerHTML).toEqual("Veröffentlichungsdatum"); |
| 1479 | expect(menu.shownItem(2).active()).toBe(false); |
| 1480 | expect(menu.container().items[0].active()).toBe(false); |
| 1481 | expect(menu.container().items[1].active()).toBe(false); |
| 1482 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1483 | }); |
| 1484 | |
| 1485 | it('should be navigatable with a prefix (1) and containerItems', function () { |
| 1486 | var menu = OwnContainerMenu.create(demolist, ExampleItemList); |
| 1487 | menu._firstActive = true; |
| 1488 | |
| 1489 | menu.limit(3); |
| 1490 | |
| 1491 | expect(menu.show()).toBe(true); |
| 1492 | expect(menu.prefix()).toEqual(""); |
| 1493 | |
| 1494 | // Add prefix in uppercase - but check in lowercase |
| 1495 | menu.prefix('El'); |
| 1496 | expect(menu.show()).toBe(true); |
| 1497 | |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1498 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1499 | expect(menu.prefix()).toEqual("El"); |
| 1500 | expect(menu._prefix.active()).toEqual(false); |
| 1501 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1502 | expect(menu.shownItem(0).active()).toBe(true); |
| 1503 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1504 | expect(menu.shownItem(1).active()).toBe(false); |
| 1505 | expect(menu.shownItem(2)).toBe(undefined); |
| 1506 | expect(menu.container().items[0].active()).toBe(false); |
| 1507 | expect(menu.container().items[1].active()).toBe(false); |
| 1508 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1509 | |
| 1510 | // Forward |
| 1511 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1512 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1513 | expect(menu.prefix()).toEqual("El"); |
| 1514 | expect(menu._prefix.active()).toEqual(false); |
| 1515 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1516 | expect(menu.shownItem(0).active()).toBe(false); |
| 1517 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1518 | expect(menu.shownItem(1).active()).toBe(true); |
| 1519 | expect(menu.shownItem(2)).toBe(undefined); |
| 1520 | expect(menu.container().items[0].active()).toBe(false); |
| 1521 | expect(menu.container().items[1].active()).toBe(false); |
| 1522 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1523 | |
| 1524 | // Forward |
| 1525 | menu.next(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1526 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1527 | expect(menu.prefix()).toEqual("El"); |
| 1528 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1529 | expect(menu.shownItem(0).active()).toBe(false); |
| 1530 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1531 | expect(menu.shownItem(1).active()).toBe(false); |
| 1532 | expect(menu.shownItem(2)).toBe(undefined); |
| 1533 | expect(menu.container().items[0].active()).toBe(true); |
| 1534 | expect(menu.container().items[1].active()).toBe(false); |
| 1535 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1536 | |
| 1537 | menu.next(); |
| 1538 | menu.next(); |
| 1539 | |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1540 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1541 | expect(menu.prefix()).toEqual("El"); |
| 1542 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1543 | expect(menu.shownItem(0).active()).toBe(false); |
| 1544 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1545 | expect(menu.shownItem(1).active()).toBe(false); |
| 1546 | expect(menu.shownItem(2)).toBe(undefined); |
| 1547 | expect(menu.container().items[0].active()).toBe(false); |
| 1548 | expect(menu.container().items[1].active()).toBe(false); |
| 1549 | expect(menu.container().items[2].active()).toBe(true); //prefix |
| 1550 | |
| 1551 | // Backward |
| 1552 | menu.prev(); |
| 1553 | menu.prev(); |
| 1554 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1555 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1556 | expect(menu.prefix()).toEqual("El"); |
| 1557 | expect(menu._prefix.active()).toEqual(false); |
| 1558 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1559 | expect(menu.shownItem(0).active()).toBe(false); |
| 1560 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1561 | expect(menu.shownItem(1).active()).toBe(true); |
| 1562 | expect(menu.shownItem(2)).toBe(undefined); |
| 1563 | expect(menu.container().items[0].active()).toBe(false); |
| 1564 | expect(menu.container().items[1].active()).toBe(false); |
| 1565 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1566 | }); |
| 1567 | |
| 1568 | |
| 1569 | it('should be navigatable with a prefix (2) and containerItems', function () { |
| 1570 | var menu = OwnContainerMenu.create(demolist,ExampleItemList); |
| 1571 | menu._firstActive = true; |
| 1572 | |
| 1573 | menu.limit(3); |
| 1574 | expect(menu.show()).toBe(true); |
| 1575 | expect(menu.prefix()).toEqual(""); |
| 1576 | menu.prefix('el'); |
| 1577 | expect(menu.show()).toBe(true); |
| 1578 | |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1579 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1580 | expect(menu.prefix()).toEqual("el"); |
| 1581 | expect(menu._prefix.active()).toEqual(false); |
| 1582 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1583 | expect(menu.shownItem(0).active()).toBe(true); |
| 1584 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1585 | expect(menu.shownItem(1).active()).toBe(false); |
| 1586 | expect(menu.shownItem(2)).toBe(undefined); |
| 1587 | expect(menu.container().items[0].active()).toBe(false); |
| 1588 | expect(menu.container().items[1].active()).toBe(false); |
| 1589 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1590 | |
| 1591 | // Backward |
| 1592 | menu.prev(); |
| 1593 | expect(menu._prefix.active()).toEqual(true); |
| 1594 | |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1595 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1596 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1597 | expect(menu.shownItem(0).active()).toBe(false); |
| 1598 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1599 | expect(menu.shownItem(1).active()).toBe(false); |
| 1600 | expect(menu.shownItem(2)).toBe(undefined); |
| 1601 | expect(menu.container().items[0].active()).toBe(false); |
| 1602 | expect(menu.container().items[1].active()).toBe(false); |
| 1603 | expect(menu.container().items[2].active()).toBe(true); //prefix |
| 1604 | |
| 1605 | // Backward |
| 1606 | menu.prev(); |
| 1607 | menu.prev(); |
| 1608 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1609 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1610 | expect(menu._prefix.active()).toEqual(false); |
| 1611 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1612 | expect(menu.shownItem(0).active()).toBe(false); |
| 1613 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1614 | expect(menu.shownItem(1).active()).toBe(true); |
| 1615 | expect(menu.shownItem(2)).toBe(undefined); |
| 1616 | expect(menu.container().items[0].active()).toBe(false); |
| 1617 | expect(menu.container().items[1].active()).toBe(false); |
| 1618 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1619 | }); |
| 1620 | |
| 1621 | it('should be navigatable with a prefix (3) and containerItems', function () { |
| 1622 | var menu = OwnContainerMenu.create(demolist,ExampleItemList); |
| 1623 | menu._firstActive = true; |
| 1624 | menu.limit(3); |
| 1625 | expect(menu.show()).toBe(true); |
| 1626 | expect(menu.prefix()).toEqual(""); |
| 1627 | menu.prefix('el'); |
| 1628 | expect(menu.show()).toBe(true); |
| 1629 | |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1630 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1631 | expect(menu.prefix()).toEqual("el"); |
| 1632 | expect(menu._prefix.active()).toEqual(false); |
| 1633 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1634 | expect(menu.shownItem(0).active()).toBe(true); |
| 1635 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1636 | expect(menu.shownItem(1).active()).toBe(false); |
| 1637 | expect(menu.shownItem(2)).toBe(undefined); |
| 1638 | expect(menu.container().items[0].active()).toBe(false); |
| 1639 | expect(menu.container().items[1].active()).toBe(false); |
| 1640 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1641 | |
| 1642 | // Backward |
| 1643 | menu.prev(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1644 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1645 | expect(menu._prefix.active()).toEqual(true); |
| 1646 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1647 | expect(menu.shownItem(0).active()).toBe(false); |
| 1648 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1649 | expect(menu.shownItem(1).active()).toBe(false); |
| 1650 | expect(menu.shownItem(2)).toBe(undefined); |
| 1651 | expect(menu.container().items[0].active()).toBe(false); |
| 1652 | expect(menu.container().items[1].active()).toBe(false); |
| 1653 | expect(menu.container().items[2].active()).toBe(true); //prefix |
| 1654 | |
| 1655 | |
| 1656 | // Forward |
| 1657 | menu.next(); |
| 1658 | expect(menu.prefix()).toEqual("el"); |
| 1659 | expect(menu._prefix.active()).toEqual(false); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 1660 | var liElements = directElementChildrenByTagName(menu.element(),"li"); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1661 | expect(liElements[0].innerHTML).toEqual("Tit<mark>el</mark>"); |
| 1662 | expect(menu.shownItem(0).active()).toBe(true); |
| 1663 | expect(liElements[1].innerHTML).toEqual("Untertit<mark>el</mark>"); |
| 1664 | expect(menu.shownItem(1).active()).toBe(false); |
| 1665 | expect(menu.shownItem(2)).toBe(undefined); |
| 1666 | expect(menu.container().items[0].active()).toBe(false); |
| 1667 | expect(menu.container().items[1].active()).toBe(false); |
| 1668 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1669 | |
| 1670 | }); |
| 1671 | |
| 1672 | it('should show screens by offset', function () { |
| 1673 | var menu = OwnContainerMenu.create(demolist,ExampleItemList); |
| 1674 | menu.limit(3); |
| 1675 | expect(menu.show()).toBe(true); |
| 1676 | |
| 1677 | expect(menu.shownItem(0).active()).toBe(false); |
| 1678 | expect(menu.shownItem(1).active()).toBe(false); |
| 1679 | expect(menu.shownItem(2).active()).toBe(false); |
| 1680 | expect(menu.container().items[0].active()).toBe(false); |
| 1681 | expect(menu.container().items[1].active()).toBe(false); |
| 1682 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1683 | |
| 1684 | // Highlight the first entry |
| 1685 | menu.next(); |
| 1686 | |
| 1687 | expect(menu.shownItem(0).active()).toBe(true); |
| 1688 | expect(menu.shownItem(1).active()).toBe(false); |
| 1689 | expect(menu.shownItem(2).active()).toBe(false); |
| 1690 | |
| 1691 | // Highlight the second entry |
| 1692 | menu.next(); |
| 1693 | |
| 1694 | expect(menu.shownItem(0).active()).toBe(false); |
| 1695 | expect(menu.shownItem(1).active()).toBe(true); |
| 1696 | expect(menu.shownItem(2).active()).toBe(false); |
| 1697 | expect(menu.shownItem(3)).toBe(undefined); |
| 1698 | |
| 1699 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1700 | expect(menu.shownItem(1).lcField()).toEqual(' untertitel'); |
| 1701 | |
| 1702 | // Move to first screen |
| 1703 | menu.screen(0); |
| 1704 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1705 | expect(menu.shownItem(1).lcField()).toEqual(' untertitel'); |
| 1706 | expect(menu.shownItem(0).active()).toBe(false); |
| 1707 | expect(menu.shownItem(1).active()).toBe(true); |
| 1708 | expect(menu.shownItem(2).active()).toBe(false); |
| 1709 | expect(menu.shownItem(3)).toBe(undefined); |
| 1710 | |
| 1711 | // Move to second screen |
| 1712 | menu.screen(1); |
| 1713 | expect(menu.shownItem(0).lcField()).toEqual(' untertitel'); |
| 1714 | expect(menu.shownItem(0).active()).toBe(true); |
| 1715 | expect(menu.shownItem(1).active()).toBe(false); |
| 1716 | expect(menu.shownItem(2).active()).toBe(false); |
| 1717 | expect(menu.shownItem(3)).toBe(undefined); |
| 1718 | |
| 1719 | menu.screen(2); |
| 1720 | expect(menu.shownItem(0).lcField()).toEqual(' veröffentlichungsdatum'); |
| 1721 | expect(menu.shownItem(0).active()).toBe(false); |
| 1722 | expect(menu.shownItem(1).active()).toBe(false); |
| 1723 | expect(menu.shownItem(2).active()).toBe(false); |
| 1724 | expect(menu.shownItem(3)).toBe(undefined); |
| 1725 | |
| 1726 | menu.screen(1); |
| 1727 | expect(menu.shownItem(0).lcField()).toEqual(' untertitel'); |
| 1728 | expect(menu.shownItem(0).active()).toBe(true); |
| 1729 | expect(menu.shownItem(1).active()).toBe(false); |
| 1730 | expect(menu.shownItem(2).active()).toBe(false); |
| 1731 | expect(menu.shownItem(3)).toBe(undefined); |
| 1732 | expect(menu.container().items[0].active()).toBe(false); |
| 1733 | expect(menu.container().items[1].active()).toBe(false); |
| 1734 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1735 | }); |
| 1736 | |
| 1737 | it('should show screens by offset when prefixed', function () { |
| 1738 | var menu = OwnContainerMenu.create(demolist,ExampleItemList); |
| 1739 | menu.limit(3); |
| 1740 | expect(menu.prefix("e").show()).toBe(true); |
| 1741 | expect(menu.shownItem(0).active()).toBe(false); |
| 1742 | expect(menu.shownItem(1).active()).toBe(false); |
| 1743 | expect(menu.shownItem(2).active()).toBe(false); |
| 1744 | expect(menu.container().items[0].active()).toBe(false); |
| 1745 | expect(menu.container().items[1].active()).toBe(false); |
| 1746 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1747 | |
| 1748 | expect(menu.shownItem(0).element().innerHTML).toEqual('Tit<mark>e</mark>l'); |
| 1749 | menu.screen(1); |
| 1750 | expect(menu.shownItem(0).element().innerHTML).toEqual('Unt<mark>e</mark>rtit<mark>e</mark>l'); |
| 1751 | }); |
| 1752 | |
| 1753 | |
| 1754 | it('should be page downable', function () { |
| 1755 | var menu = OwnContainerMenu.create(demolonglist,ExampleItemList); |
| 1756 | menu.limit(3); |
| 1757 | |
| 1758 | expect(menu.show(0)).toBe(true); |
| 1759 | |
| 1760 | expect(menu.container().items[0].active()).toBe(false); |
| 1761 | expect(menu.container().items[1].active()).toBe(false); |
| 1762 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1763 | |
| 1764 | expect(menu.shownItem(0).active()).toBe(true); |
| 1765 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1766 | expect(menu.shownItem(1).active()).toBe(false); |
| 1767 | expect(menu.shownItem(2).active()).toBe(false); |
| 1768 | expect(menu.shownItem(3)).toBe(undefined); |
| 1769 | |
| 1770 | menu.pageDown(); |
| 1771 | |
| 1772 | expect(menu.shownItem(0).lcField()).toEqual(' länge'); |
| 1773 | expect(menu.shownItem(0).active()).toBe(false); |
| 1774 | expect(menu.shownItem(1).active()).toBe(false); |
| 1775 | expect(menu.shownItem(2).active()).toBe(false); |
| 1776 | |
| 1777 | menu.pageDown(); |
| 1778 | |
| 1779 | expect(menu.shownItem(0).lcField()).toEqual(' corpusid'); |
| 1780 | expect(menu.shownItem(0).active()).toBe(false); |
| 1781 | expect(menu.shownItem(1).active()).toBe(false); |
| 1782 | expect(menu.shownItem(2).active()).toBe(false); |
| 1783 | |
| 1784 | // Doesn't matter |
| 1785 | menu.pageDown(); |
| 1786 | |
| 1787 | expect(menu.shownItem(0).lcField()).toEqual(' corpusid'); |
| 1788 | expect(menu.shownItem(0).active()).toBe(false); |
| 1789 | expect(menu.shownItem(1).active()).toBe(false); |
| 1790 | expect(menu.shownItem(2).active()).toBe(false); |
| 1791 | expect(menu.container().items[0].active()).toBe(false); |
| 1792 | expect(menu.container().items[1].active()).toBe(false); |
| 1793 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1794 | }); |
| 1795 | |
| 1796 | it('should be page downable with prefix', function () { |
| 1797 | var menu = OwnContainerMenu.create(demolonglist,ExampleItemList); |
| 1798 | menu.limit(3); |
| 1799 | |
| 1800 | expect(menu.prefix('e').show(0)).toBe(true); |
| 1801 | |
| 1802 | expect(menu.shownItem(0).active()).toBe(true); |
| 1803 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1804 | expect(menu.shownItem(1).active()).toBe(false); |
| 1805 | expect(menu.shownItem(1).lcField()).toEqual(' untertitel'); |
| 1806 | expect(menu.shownItem(2).active()).toBe(false); |
| 1807 | expect(menu.shownItem(2).lcField()).toEqual(' veröffentlichungsdatum'); |
| 1808 | expect(menu.shownItem(3)).toBe(undefined); |
| 1809 | |
| 1810 | expect(menu.container().items[0].active()).toBe(false); |
| 1811 | expect(menu.container().items[1].active()).toBe(false); |
| 1812 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1813 | |
| 1814 | menu.pageDown(); |
| 1815 | |
| 1816 | expect(menu.shownItem(0).active()).toBe(false); |
| 1817 | expect(menu.shownItem(0).lcField()).toEqual(' länge'); |
| 1818 | expect(menu.shownItem(1).active()).toBe(false); |
| 1819 | expect(menu.shownItem(1).lcField()).toEqual(' genre'); |
| 1820 | expect(menu.shownItem(2).active()).toBe(false); |
| 1821 | expect(menu.shownItem(2).lcField()).toEqual(' textid'); |
| 1822 | |
| 1823 | // Doesn't matter |
| 1824 | menu.pageDown(); |
| 1825 | |
| 1826 | expect(menu.shownItem(0).active()).toBe(false); |
| 1827 | expect(menu.shownItem(0).lcField()).toEqual(' länge'); |
| 1828 | expect(menu.shownItem(1).active()).toBe(false); |
| 1829 | expect(menu.shownItem(1).lcField()).toEqual(' genre'); |
| 1830 | expect(menu.shownItem(2).active()).toBe(false); |
| 1831 | expect(menu.shownItem(2).lcField()).toEqual(' textid'); |
| 1832 | expect(menu.container().items[0].active()).toBe(false); |
| 1833 | expect(menu.container().items[1].active()).toBe(false); |
| 1834 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1835 | }); |
| 1836 | |
| 1837 | |
| 1838 | it('should be page upable', function () { |
| 1839 | var menu = OwnContainerMenu.create(demolonglist,ExampleItemList); |
| 1840 | menu.limit(3); |
| 1841 | |
| 1842 | // Choose the final value |
| 1843 | expect(menu.show(1000)).toBe(true); |
| 1844 | |
| 1845 | expect(menu.shownItem(0).active()).toBe(false); |
| 1846 | expect(menu.shownItem(1).active()).toBe(false); |
| 1847 | expect(menu.shownItem(2).active()).toBe(true); |
| 1848 | expect(menu.shownItem(2).lcField()).toEqual(' textid'); |
| 1849 | expect(menu.shownItem(3)).toBe(undefined); |
| 1850 | expect(menu.container().items[0].active()).toBe(false); |
| 1851 | expect(menu.container().items[1].active()).toBe(false); |
| 1852 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1853 | |
| 1854 | menu.pageUp(); |
| 1855 | |
| 1856 | expect(menu.shownItem(0).lcField()).toEqual(' länge'); |
| 1857 | expect(menu.shownItem(0).active()).toBe(false); |
| 1858 | expect(menu.shownItem(1).active()).toBe(false); |
| 1859 | expect(menu.shownItem(2).active()).toBe(false); |
| 1860 | |
| 1861 | menu.pageUp(); |
| 1862 | |
| 1863 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1864 | expect(menu.shownItem(0).active()).toBe(false); |
| 1865 | expect(menu.shownItem(1).active()).toBe(false); |
| 1866 | expect(menu.shownItem(2).active()).toBe(false); |
| 1867 | |
| 1868 | // Doesn't matter |
| 1869 | menu.pageUp(); |
| 1870 | |
| 1871 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1872 | expect(menu.shownItem(0).active()).toBe(false); |
| 1873 | expect(menu.shownItem(1).active()).toBe(false); |
| 1874 | expect(menu.shownItem(2).active()).toBe(false); |
| 1875 | expect(menu.container().items[0].active()).toBe(false); |
| 1876 | expect(menu.container().items[1].active()).toBe(false); |
| 1877 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1878 | }); |
| 1879 | |
| 1880 | it('should be page upable with prefix', function () { |
| 1881 | var menu = OwnContainerMenu.create(demolonglist,ExampleItemList); |
| 1882 | menu.limit(3); |
| 1883 | |
| 1884 | // Choose the final value |
| 1885 | expect(menu.prefix("e").show(1000)).toBe(true); |
| 1886 | |
| 1887 | expect(menu.shownItem(0).active()).toBe(false); |
| 1888 | expect(menu.shownItem(0).lcField()).toEqual(' länge'); |
| 1889 | expect(menu.shownItem(1).active()).toBe(false); |
| 1890 | expect(menu.shownItem(1).lcField()).toEqual(' genre'); |
| 1891 | expect(menu.shownItem(2).active()).toBe(true); |
| 1892 | expect(menu.shownItem(2).lcField()).toEqual(' textid'); |
| 1893 | expect(menu.shownItem(3)).toBe(undefined); |
| 1894 | expect(menu.container().items[0].active()).toBe(false); |
| 1895 | expect(menu.container().items[1].active()).toBe(false); |
| 1896 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1897 | |
| 1898 | menu.pageUp(); |
| 1899 | |
| 1900 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1901 | expect(menu.shownItem(0).active()).toBe(false); |
| 1902 | expect(menu.shownItem(1).active()).toBe(false); |
| 1903 | expect(menu.shownItem(1).lcField()).toEqual(' untertitel'); |
| 1904 | expect(menu.shownItem(2).active()).toBe(false); |
| 1905 | expect(menu.shownItem(2).lcField()).toEqual(' veröffentlichungsdatum'); |
| 1906 | |
| 1907 | // Doesn't matter |
| 1908 | menu.pageUp(); |
| 1909 | |
| 1910 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1911 | expect(menu.shownItem(0).active()).toBe(false); |
| 1912 | expect(menu.shownItem(1).active()).toBe(false); |
| 1913 | expect(menu.shownItem(1).lcField()).toEqual(' untertitel'); |
| 1914 | expect(menu.shownItem(2).active()).toBe(false); |
| 1915 | expect(menu.shownItem(2).lcField()).toEqual(' veröffentlichungsdatum'); |
| 1916 | expect(menu.container().items[0].active()).toBe(false); |
| 1917 | expect(menu.container().items[1].active()).toBe(false); |
| 1918 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1919 | }); |
| 1920 | |
| 1921 | it('should be view upable and downable (1)', function () { |
| 1922 | var menu = OwnContainerMenu.create(demolonglist,ExampleItemList); |
| 1923 | menu.limit(7); |
| 1924 | |
| 1925 | // Choose the final value |
| 1926 | expect(menu.show(1)).toBe(true); |
| 1927 | |
| 1928 | expect(menu.shownItem(0).active()).toBe(false); |
| 1929 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1930 | expect(menu.shownItem(1).active()).toBe(true); |
| 1931 | expect(menu.shownItem(2).active()).toBe(false); |
| 1932 | expect(menu.shownItem(2).lcField()).toEqual(' veröffentlichungsdatum'); |
| 1933 | expect(menu.shownItem(6).active()).toBe(false); |
| 1934 | expect(menu.shownItem(7)).toBe(undefined); |
| 1935 | expect(menu.container().items[0].active()).toBe(false); |
| 1936 | expect(menu.container().items[1].active()).toBe(false); |
| 1937 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1938 | |
| 1939 | // Doesn't change anything |
| 1940 | menu.viewUp(); |
| 1941 | |
| 1942 | expect(menu.shownItem(0).active()).toBe(false); |
| 1943 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1944 | expect(menu.shownItem(1).active()).toBe(true); |
| 1945 | |
| 1946 | menu.viewDown(); |
| 1947 | |
| 1948 | expect(menu.shownItem(0).active()).toBe(true); |
| 1949 | expect(menu.shownItem(0).lcField()).toEqual(' untertitel'); |
| 1950 | expect(menu.shownItem(1).active()).toBe(false); |
| 1951 | |
| 1952 | menu.viewDown(); |
| 1953 | |
| 1954 | expect(menu.shownItem(0).active()).toBe(false); |
| 1955 | expect(menu.shownItem(0).lcField()).toEqual(' veröffentlichungsdatum'); |
| 1956 | expect(menu.shownItem(1).active()).toBe(false); |
| 1957 | |
| 1958 | // No effect anymore |
| 1959 | menu.viewDown(); |
| 1960 | |
| 1961 | expect(menu.shownItem(0).active()).toBe(false); |
| 1962 | expect(menu.shownItem(0).lcField()).toEqual(' veröffentlichungsdatum'); |
| 1963 | expect(menu.shownItem(1).active()).toBe(false); |
| 1964 | expect(menu.container().items[0].active()).toBe(false); |
| 1965 | expect(menu.container().items[1].active()).toBe(false); |
| 1966 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1967 | }); |
| 1968 | |
| 1969 | it('should be view upable and downable (2)', function () { |
| 1970 | |
| 1971 | // List is longer than limit |
| 1972 | var menu = OwnContainerMenu.create(demolist,ExampleItemList); |
| 1973 | menu.limit(7); |
| 1974 | |
| 1975 | // Choose the final value |
| 1976 | expect(menu.show(1)).toBe(true); |
| 1977 | |
| 1978 | expect(menu.shownItem(0).active()).toBe(false); |
| 1979 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1980 | expect(menu.shownItem(1).active()).toBe(true); |
| 1981 | expect(menu.shownItem(2).active()).toBe(false); |
| 1982 | expect(menu.shownItem(2).lcField()).toEqual(' veröffentlichungsdatum'); |
| 1983 | expect(menu.shownItem(4).active()).toBe(false); |
| 1984 | expect(menu.shownItem(5)).toBe(undefined); |
| 1985 | expect(menu.container().items[0].active()).toBe(false); |
| 1986 | expect(menu.container().items[1].active()).toBe(false); |
| 1987 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 1988 | |
| 1989 | // Doesn't change anything |
| 1990 | menu.viewUp(); |
| 1991 | |
| 1992 | expect(menu.shownItem(0).active()).toBe(false); |
| 1993 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 1994 | expect(menu.shownItem(1).active()).toBe(true); |
| 1995 | |
| 1996 | menu.viewDown(); |
| 1997 | |
| 1998 | expect(menu.shownItem(0).active()).toBe(false); |
| 1999 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 2000 | expect(menu.shownItem(1).active()).toBe(true); |
| 2001 | expect(menu.container().items[0].active()).toBe(false); |
| 2002 | expect(menu.container().items[1].active()).toBe(false); |
| 2003 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 2004 | }); |
| 2005 | |
| 2006 | |
| 2007 | it('should scroll to a chosen value (1)', function () { |
| 2008 | var menu = OwnContainerMenu.create(demolist,ExampleItemList); |
| 2009 | menu.limit(3); |
| 2010 | |
| 2011 | // Choose value 1 |
| 2012 | expect(menu.show(1)).toBe(true); |
| 2013 | |
| 2014 | expect(menu.shownItem(0).active()).toBe(false); |
| 2015 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 2016 | expect(menu.shownItem(1).active()).toBe(true); |
| 2017 | expect(menu.shownItem(2).active()).toBe(false); |
| 2018 | expect(menu.shownItem(3)).toBe(undefined); |
| 2019 | expect(menu.container().items[0].active()).toBe(false); |
| 2020 | expect(menu.container().items[1].active()).toBe(false); |
| 2021 | expect(menu.container().items[2].active()).toBe(false); //prefix |
| 2022 | |
| 2023 | // Choose value 2 |
| 2024 | expect(menu.show(2)).toBe(true); |
| 2025 | |
| 2026 | expect(menu.shownItem(0).active()).toBe(false); |
| 2027 | expect(menu.shownItem(0).lcField()).toEqual(' titel'); |
| 2028 | expect(menu.shownItem(1).active()).toBe(false); |
| 2029 | expect(menu.shownItem(2).active()).toBe(true); |
| 2030 | expect(menu.shownItem(3)).toBe(undefined); |
| 2031 | }); |
| 2032 | |
| 2033 | it('should scroll to a chosen value (2)', function () { |
| 2034 | var menu = OwnContainerMenu.create(demolonglist,ExampleItemList); |
| 2035 | |
| 2036 | // Choose value 3 |
| 2037 | expect(menu.limit(3).show(3)).toBe(true); |
| 2038 | expect(menu.shownItem(0).lcField()).toEqual(' länge'); |
| 2039 | expect(menu.shownItem(0).active()).toBe(true); |
| 2040 | expect(menu.shownItem(1).active()).toBe(false); |
| 2041 | expect(menu.shownItem(2).active()).toBe(false); |
| 2042 | expect(menu.shownItem(3)).toBe(undefined); |
| 2043 | }); |
| 2044 | |
| 2045 | xit('should scroll to a chosen value after prefixing, if the chosen value is live'); |
| 2046 | |
| 2047 | it('should be extendable', function () { |
| 2048 | var menu = OwnContainerMenu.create([],ExampleItemList); |
| 2049 | let entryData = 'empty'; |
| 2050 | menu._itemClass = menuItemClass; |
| 2051 | menu.readItems([ |
| 2052 | ['a', '', function () { entryData = 'a' }], |
| 2053 | ['bb', '', function () { entryData = 'bb' }], |
| 2054 | ['ccc', '', function () { entryData = 'ccc' }], |
| 2055 | ]); |
| 2056 | expect(menu.limit(3).show(3)).toBe(true); |
| 2057 | expect(menu.shownItem(0).lcField()).toEqual(' a'); |
| 2058 | expect(menu.shownItem(1).lcField()).toEqual(' bb'); |
| 2059 | expect(menu.shownItem(2).lcField()).toEqual(' ccc'); |
| 2060 | expect(entryData).toEqual('empty'); |
| 2061 | menu.shownItem(1).element().click(); |
| 2062 | expect(entryData).toEqual('bb'); |
| 2063 | expect(menu.lengthField().element().innerText).toEqual("a--bb--ccc--") |
| 2064 | expect(menu.slider().length()).toEqual(3); |
| 2065 | let obj = menu.itemClass().create( |
| 2066 | ['dddd','',function () { entryData = 'dddd'} ] |
| 2067 | ); |
| 2068 | menu.append(obj); |
| 2069 | expect(menu.limit(2).show(1)).toBe(true); |
| 2070 | expect(menu.shownItem(0).lcField()).toEqual(' a'); |
| 2071 | expect(menu.shownItem(1).lcField()).toEqual(' bb'); |
| 2072 | menu.next(); |
| 2073 | expect(menu.shownItem(1).lcField()).toEqual(' ccc'); |
| 2074 | menu.next(); |
| 2075 | expect(menu.shownItem(1).lcField()).toEqual(' dddd'); |
| 2076 | menu.next(); |
| 2077 | menu.next(); |
| 2078 | menu.next(); |
| 2079 | expect(menu.shownItem(0).lcField()).toEqual(' a'); |
| 2080 | expect(menu.lengthField().element().innerText).toEqual("a--bb--ccc--dddd--") |
| 2081 | expect(menu.slider().length()).toEqual(4); |
| 2082 | }); |
| 2083 | }); |
Leo Repp | c66268e | 2021-10-28 11:44:35 +0200 | [diff] [blame] | 2084 | |
| 2085 | describe('KorAP.ContainerMenu.Container', function () { |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 2086 | it("should be initializable with no additional container items", function () { |
| 2087 | var list = [ |
| 2088 | ["Constituency"], |
| 2089 | ["Lemma"], |
| 2090 | ["Morphology"], |
| 2091 | ["Part-of-Speech"], |
| 2092 | ["Syntax"] |
| 2093 | ]; |
| 2094 | var menu = OwnContainerMenu.create(list); |
| 2095 | var container = menu.container(); |
| 2096 | expect(container._containerItemClass).toEqual(OwnContainerItemClass); |
| 2097 | expect(container.element().nodeName).toEqual("UL"); |
| 2098 | expect(container.element().classList.contains("menu")).toBeTruthy(); |
| 2099 | expect(container.element().classList.contains("visible")).toBeFalsy(); |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 2100 | expect(menu._prefix).toEqual(container._cItemPrefix); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 2101 | expect(container.length()).toEqual(1); |
| 2102 | expect(container.length()).toEqual(container.items.length); |
| 2103 | expect(container.liveLength()).toEqual(0); |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 2104 | expect(container.item(0)).toEqual(container._cItemPrefix); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 2105 | expect(container.active()).toBeFalsy(); |
Leo Repp | dedcf1a | 2021-08-18 18:57:47 +0200 | [diff] [blame] | 2106 | expect(directElementChildrenByTagName(menu.element(),"pref")).toEqual([]); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 2107 | expect(container.element().getElementsByClassName("pref").length).toEqual(1); |
| 2108 | |
| 2109 | |
| 2110 | |
| 2111 | menu.prefix("ad"); |
| 2112 | expect(container.liveLength()).toEqual(1); |
| 2113 | menu.prev(); |
| 2114 | expect(container.active()).toBeTruthy(); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 2115 | }); |
| 2116 | |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 2117 | it("should support dynamic changing of text content", function () { |
| 2118 | var list = [ |
| 2119 | ["Constituency"], |
| 2120 | ["Lemma"], |
| 2121 | ["Morphology"], |
| 2122 | ["Part-of-Speech"], |
| 2123 | ["Syntax"] |
| 2124 | ]; |
| 2125 | |
| 2126 | var ExampleItemList2 = new Array; |
| 2127 | ExampleItemList2.push({defaultTextValue : "CIText1 "}); |
| 2128 | ExampleItemList2.push({}); |
| 2129 | |
| 2130 | var menu = OwnContainerMenu.create(list,ExampleItemList2); |
| 2131 | var container = menu.container(); |
| 2132 | expect(container.item(0).content().nodeValue).toEqual("CIText1 "); |
| 2133 | expect(container.item(1).content().nodeValue).toEqual(""); |
| 2134 | expect(container.item(2)).toBeDefined(); |
| 2135 | expect(container.item(2).content()).toEqual(undefined); |
| 2136 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2137 | expect(container.item(0).content("New1").nodeValue).toEqual("New1"); |
| 2138 | expect(container.item(1).content("New2").nodeValue).toEqual("New2"); |
| 2139 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2140 | expect(container.item(2)).toBeDefined(); |
| 2141 | expect(container.item(2).content()).toEqual(undefined); |
| 2142 | expect(container.item(0).content().nodeValue).toEqual("CIText1 "); |
| 2143 | expect(container.item(1).content().nodeValue).toEqual(""); |
| 2144 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2145 | expect(container.item(2)).toBeDefined(); |
| 2146 | expect(container.item(2).content()).toEqual(undefined); |
| 2147 | |
| 2148 | |
| 2149 | }); |
| 2150 | |
| 2151 | it("should support dynamic adding of items", function () { |
| 2152 | |
| 2153 | var list = [ |
| 2154 | ["Constituency"], |
| 2155 | ["Lemma"], |
| 2156 | ["Morphology"], |
| 2157 | ["Part-of-Speech"], |
| 2158 | ["Syntax"] |
| 2159 | ]; |
| 2160 | |
| 2161 | var ExampleItemList2 = new Array; |
| 2162 | ExampleItemList2.push({defaultTextValue : "CIText1 "}); |
| 2163 | ExampleItemList2.push({}); |
| 2164 | |
| 2165 | var menu = OwnContainerMenu.create(list,ExampleItemList2); |
| 2166 | var container = menu.container(); |
| 2167 | expect(container.item(0).content().nodeValue).toEqual("CIText1 "); |
| 2168 | expect(container.item(1).content().nodeValue).toEqual(""); |
| 2169 | expect(container.item(2).content()).toEqual(undefined); |
| 2170 | expect(container.item(2)).toBeDefined(); |
| 2171 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2172 | container.addItem({defaultTextValue : "CIText2 "}); |
| 2173 | expect(container.item(0).content().nodeValue).toEqual("CIText1 "); |
| 2174 | expect(container.item(1).content().nodeValue).toEqual(""); |
| 2175 | expect(container.item(2).content().nodeValue).toEqual("CIText2 "); |
| 2176 | expect(container.item(3)).toBeDefined(); |
| 2177 | expect(container.item(3).content()).toEqual(undefined); |
| 2178 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2179 | container.add("a"); |
| 2180 | |
| 2181 | menu.next(); |
| 2182 | menu.next(); |
| 2183 | menu.next(); |
| 2184 | menu.next(); |
| 2185 | menu.next(); |
| 2186 | expect(container.item(0).active()).toBeTruthy(); |
| 2187 | menu.next(); |
| 2188 | expect(container.item(1).active()).toBeTruthy(); |
| 2189 | menu.next(); |
| 2190 | expect(container.item(2).active()).toBeTruthy(); |
| 2191 | menu.next(); |
| 2192 | expect(container.item(3).active()).toBeTruthy(); |
| 2193 | menu.next(); |
| 2194 | expect(container.item(3).active()).toBeFalsy(); |
| 2195 | menu.prev(); |
| 2196 | expect(container.item(3).active()).toBeTruthy(); |
| 2197 | menu.prev(); |
| 2198 | expect(container.item(2).active()).toBeTruthy(); |
| 2199 | menu.prev(); |
| 2200 | expect(container.item(1).active()).toBeTruthy(); |
| 2201 | menu.prev(); |
| 2202 | expect(container.item(0).active()).toBeTruthy(); |
| 2203 | menu.prev(); |
| 2204 | expect(container.item(0).active()).toBeFalsy(); |
| 2205 | |
| 2206 | |
| 2207 | |
| 2208 | }); |
| 2209 | |
| 2210 | it("should support dynamic changing of text content", function () { |
| 2211 | var list = [ |
| 2212 | ["Constituency"], |
| 2213 | ["Lemma"], |
| 2214 | ["Morphology"], |
| 2215 | ["Part-of-Speech"], |
| 2216 | ["Syntax"] |
| 2217 | ]; |
| 2218 | |
| 2219 | var ExampleItemList2 = new Array; |
| 2220 | ExampleItemList2.push({defaultTextValue : "CIText1 "}); |
| 2221 | ExampleItemList2.push({}); |
| 2222 | |
| 2223 | var menu = OwnContainerMenu.create(list,ExampleItemList2); |
| 2224 | var container = menu.container(); |
| 2225 | expect(container.item(0).content().nodeValue).toEqual("CIText1 "); |
| 2226 | expect(container.item(1).content().nodeValue).toEqual(""); |
| 2227 | expect(container.item(2)).toBeDefined(); |
| 2228 | expect(container.item(2).content()).toEqual(undefined); |
| 2229 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2230 | expect(container.item(0).content("New1").nodeValue).toEqual("New1"); |
| 2231 | expect(container.item(1).content("New2").nodeValue).toEqual("New2"); |
| 2232 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2233 | expect(container.item(2)).toBeDefined(); |
| 2234 | expect(container.item(2).content()).toEqual(undefined); |
| 2235 | expect(container.item(0).content().nodeValue).toEqual("CIText1 "); |
| 2236 | expect(container.item(1).content().nodeValue).toEqual(""); |
| 2237 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2238 | expect(container.item(2)).toBeDefined(); |
| 2239 | expect(container.item(2).content()).toEqual(undefined); |
| 2240 | |
| 2241 | |
| 2242 | }); |
| 2243 | |
| 2244 | it("should support dynamic adding of items", function () { |
| 2245 | |
| 2246 | var list = [ |
| 2247 | ["Constituency"], |
| 2248 | ["Lemma"], |
| 2249 | ["Morphology"], |
| 2250 | ["Part-of-Speech"], |
| 2251 | ["Syntax"] |
| 2252 | ]; |
| 2253 | |
| 2254 | var ExampleItemList2 = new Array; |
| 2255 | ExampleItemList2.push({defaultTextValue : "CIText1 "}); |
| 2256 | ExampleItemList2.push({}); |
| 2257 | |
| 2258 | var menu = OwnContainerMenu.create(list,ExampleItemList2); |
| 2259 | var container = menu.container(); |
| 2260 | expect(container.item(0).content().nodeValue).toEqual("CIText1 "); |
| 2261 | expect(container.item(1).content().nodeValue).toEqual(""); |
| 2262 | expect(container.item(2).content()).toEqual(undefined); |
| 2263 | expect(container.item(2)).toBeDefined(); |
| 2264 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2265 | container.addItem({defaultTextValue : "CIText2 "}); |
| 2266 | expect(container.item(0).content().nodeValue).toEqual("CIText1 "); |
| 2267 | expect(container.item(1).content().nodeValue).toEqual(""); |
| 2268 | expect(container.item(2).content().nodeValue).toEqual("CIText2 "); |
| 2269 | expect(container.item(3)).toBeDefined(); |
| 2270 | expect(container.item(3).content()).toEqual(undefined); |
| 2271 | expect(container._cItemPrefix.element().innerHTML).toEqual(""); |
| 2272 | container.add("a"); |
| 2273 | |
| 2274 | menu.next(); |
| 2275 | menu.next(); |
| 2276 | menu.next(); |
| 2277 | menu.next(); |
| 2278 | menu.next(); |
| 2279 | expect(container.item(0).active()).toBeTruthy(); |
| 2280 | menu.next(); |
| 2281 | expect(container.item(1).active()).toBeTruthy(); |
| 2282 | menu.next(); |
| 2283 | expect(container.item(2).active()).toBeTruthy(); |
| 2284 | menu.next(); |
| 2285 | expect(container.item(3).active()).toBeTruthy(); |
| 2286 | menu.next(); |
| 2287 | expect(container.item(3).active()).toBeFalsy(); |
| 2288 | menu.prev(); |
| 2289 | expect(container.item(3).active()).toBeTruthy(); |
| 2290 | menu.prev(); |
| 2291 | expect(container.item(2).active()).toBeTruthy(); |
| 2292 | menu.prev(); |
| 2293 | expect(container.item(1).active()).toBeTruthy(); |
| 2294 | menu.prev(); |
| 2295 | expect(container.item(0).active()).toBeTruthy(); |
| 2296 | menu.prev(); |
| 2297 | expect(container.item(0).active()).toBeFalsy(); |
| 2298 | |
| 2299 | |
| 2300 | |
| 2301 | }); |
| 2302 | |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 2303 | }); |
| 2304 | }); |