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