blob: 76da135e4a0688d41ea63454e04c0c1d447909dd [file] [log] [blame]
Nils Diewald2fe12e12015-03-06 16:47:06 +00001// The OwnMenu item
Nils Diewaldfda29d92015-01-22 17:28:01 +00002KorAP.OwnMenuItem = {
3 create : function (params) {
4 return Object.create(KorAP.MenuItem).upgradeTo(KorAP.OwnMenuItem)._init(params);
5 },
6 content : function (content) {
7 if (arguments.length === 1) {
8 this._content = content;
9 };
10 return this._content;
11 },
12 _init : function (params) {
13 if (params[0] === undefined)
14 throw new Error("Missing parameters");
15
16 this._content = document.createTextNode(params[0]);
17 this._lcField = ' ' + this.content().textContent.toLowerCase();
18
19 return this;
20 }
21};
22
Nils Diewaldfda29d92015-01-22 17:28:01 +000023
Nils Diewald2fe12e12015-03-06 16:47:06 +000024// The OwnMenu
Nils Diewald86dad5b2015-01-28 15:09:07 +000025KorAP.OwnMenu = {
26 create : function (params) {
27 return Object.create(KorAP.Menu)
28 .upgradeTo(KorAP.OwnMenu)
29 ._init(KorAP.OwnMenuItem, params);
30 }
31};
32
33
Nils Diewald2fe12e12015-03-06 16:47:06 +000034// HintMenuItem
Nils Diewald86dad5b2015-01-28 15:09:07 +000035KorAP.HintMenuItem = {
36 create : function (params) {
37 return Object.create(KorAP.MenuItem)
38 .upgradeTo(KorAP.HintMenuItem)
39 ._init(params);
40 },
41 content : function (content) {
42 if (arguments.length === 1) {
43 this._content = content;
44 };
45 return this._content;
46 },
47 _init : function (params) {
48 if (params[0] === undefined || params[1] === undefined)
49 throw new Error("Missing parameters");
50
51 this._name = params[0];
52 this._action = params[1];
53 this._lcField = ' ' + this._name.toLowerCase();
54
55 if (params.length > 2) {
56 this._desc = params[2];
57 this._lcField += " " + this._desc.toLowerCase();
58 };
59
60 return this;
61 },
62 name : function () {
63 return this._name;
64 },
65 action : function () {
66 return this._action;
67 },
68 desc : function () {
69 return this._desc;
70 },
71 element : function () {
72 // already defined
73 if (this._element !== undefined)
74 return this._element;
75
76 // Create list item
77 var li = document.createElement("li");
78 li.setAttribute("data-action", this._action);
79
80 // Create title
81 var name = document.createElement("strong");
82 name.appendChild(document.createTextNode(this._name));
83
84 li.appendChild(name);
85
86 // Create description
87 if (this._desc !== undefined) {
88 var desc = document.createElement("span");
89 desc.appendChild(document.createTextNode(this._desc));
90 li.appendChild(desc);
91 };
92 return this._element = li;
93 }
94};
95
96
Nils Diewald2fe12e12015-03-06 16:47:06 +000097// HintMenu
98KorAP.HintMenu = {
99 create : function (context, params) {
100 var obj = Object.create(KorAP.Menu)
101 .upgradeTo(KorAP.HintMenu)
102 ._init(KorAP.HintMenuItem, params);
103 obj._context = context;
104 return obj;
105 }
106};
107
108
109// The ComplexMenuItem
110KorAP.ComplexMenuItem = {
111 create : function (params) {
112 return Object.create(KorAP.MenuItem)
113 .upgradeTo(KorAP.ComplexMenuItem)
114 ._init(params);
115 },
116 content : function (content) {
117 if (arguments.length === 1) {
118 this._content = content;
119 };
120 return this._content;
121 },
122 _init : function (params) {
123 if (params[0] === undefined)
124 throw new Error("Missing parameters");
125
126 var r = document.createElement('div');
127 for (var i = 1; i <= params.length; i++) {
128 var h = document.createElement('h' + i);
129 h.appendChild(document.createTextNode(params[i-1]));
130 r.appendChild(h);
131 };
132
133 this._content = r;
134 this._lcField = ' ' + this.content().textContent.toLowerCase();
135
136 return this;
137 }
138};
139
140
Nils Diewaldfda29d92015-01-22 17:28:01 +0000141
142describe('KorAP.MenuItem', function () {
143 it('should be initializable', function () {
144 expect(
145 function() { KorAP.MenuItem.create([]) }
146 ).toThrow(new Error("Missing parameters"));
147
148 expect(
149 function() { KorAP.OwnMenuItem.create([]) }
150 ).toThrow(new Error("Missing parameters"));
151
152 var mi = KorAP.OwnMenuItem.create(["Baum"]);
153 expect(mi.element().firstChild.nodeValue).toEqual('Baum');
154 expect(mi.lcField()).toEqual(' baum');
155 });
156
157 it('should be activatable and deactivateable by class', function () {
158 var menuItem = KorAP.OwnMenuItem.create(['Test']);
159
160 expect(menuItem.active()).toBe(false);
161 expect(menuItem.element().getAttribute("class")).toBe(null);
162 menuItem.active(true);
163 expect(menuItem.active()).toBe(true);
164 expect(menuItem.element().getAttribute("class")).toEqual("active");
165 menuItem.active(false); // Is active
166 expect(menuItem.active()).toBe(false);
167 expect(menuItem.element().getAttribute("class")).toEqual("");
168 menuItem.active(true);
169 expect(menuItem.active()).toBe(true);
170 expect(menuItem.element().getAttribute("class")).toEqual("active");
171
172 menuItem = KorAP.OwnMenuItem.create(['Spiegel']);
173 expect(menuItem.active()).toBe(false);
174 expect(menuItem.element().getAttribute("class")).toBe(null);
175 menuItem.active(false); // Is not active
176 expect(menuItem.active()).toBe(false);
177 expect(menuItem.element().getAttribute("class")).toBe(null);
178 });
179
180 it('should be set to boundary', function () {
181 var menuItem = KorAP.OwnMenuItem.create(['CoreNLP']);
182 expect(menuItem.active()).toBe(false);
183 expect(menuItem.element().getAttribute("class")).toBe(null);
184
185 // Set active
186 menuItem.active(true);
187 expect(menuItem.active()).toBe(true);
188 expect(menuItem.noMore()).toBe(false);
189 expect(menuItem.element().getAttribute("class")).toEqual("active");
190
191 // Set no more
192 menuItem.noMore(true);
193 expect(menuItem.active()).toBe(true);
194 expect(menuItem.noMore()).toBe(true);
195 expect(menuItem.element().getAttribute("class")).toEqual("active no-more");
196
197 // No no more
198 menuItem.noMore(false);
199 expect(menuItem.active()).toBe(true);
200 expect(menuItem.noMore()).toBe(false);
201 expect(menuItem.element().getAttribute("class")).toEqual("active");
202
203 // Set no more, deactivate
204 menuItem.noMore(true);
205 menuItem.active(false);
206 expect(menuItem.active()).toBe(false);
207 expect(menuItem.noMore()).toBe(true);
208 expect(menuItem.element().getAttribute("class")).toEqual("no-more");
209
210 // Set active
211 menuItem.active(true);
212 expect(menuItem.active()).toBe(true);
213 expect(menuItem.noMore()).toBe(true);
214 expect(menuItem.element().getAttribute("class")).toEqual("no-more active");
215 });
216
217
218 it('should be highlightable', function () {
219 // Highlight in the middle
220 var menuItem = KorAP.OwnMenuItem.create(['CoreNLP']);
221 menuItem.highlight("ren");
222 expect(menuItem.element().innerHTML).toEqual("Co<mark>reN</mark>LP");
223
224 menuItem.lowlight();
225 expect(menuItem.element().innerHTML).toEqual("CoreNLP");
226
227 var plain = "<div><h1>CoreNLP</h1><h2>corenlp/</h2></div>";
228
229 // Starting highlight
230 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/']);
231 menuItem.highlight("cor");
232 expect(menuItem.element().innerHTML).toEqual("<div><h1><mark>Cor</mark>eNLP</h1><h2><mark>cor</mark>enlp/</h2></div>");
233
234 menuItem.lowlight();
235 expect(menuItem.element().innerHTML).toEqual(plain);
236
237 // Starting highlight - short
238 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/']);
239 menuItem.highlight("c");
240 expect(menuItem.element().innerHTML).toEqual("<div><h1><mark>C</mark>oreNLP</h1><h2><mark>c</mark>orenlp/</h2></div>");
241
242 menuItem.lowlight();
243 expect(menuItem.element().innerHTML).toEqual(plain);
244
245 // Highlight at the end
246 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/']);
247 menuItem.highlight("nlp");
248 expect(menuItem.element().innerHTML).toEqual("<div><h1>Core<mark>NLP</mark></h1><h2>core<mark>nlp</mark>/</h2></div>");
249
250 menuItem.lowlight();
251 expect(menuItem.element().innerHTML).toEqual(plain);
252
253 // Highlight at the end - short
254 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/']);
255 menuItem.highlight("p");
256 expect(menuItem.element().innerHTML).toEqual("<div><h1>CoreNL<mark>P</mark></h1><h2>corenl<mark>p</mark>/</h2></div>");
257
258 menuItem.lowlight();
259 expect(menuItem.element().innerHTML).toEqual(plain);
260
261 // No highlight
262 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/']);
263 menuItem.highlight("xp");
264 expect(menuItem.element().innerHTML).toEqual(plain);
265
266 menuItem.lowlight();
267 expect(menuItem.element().innerHTML).toEqual(plain);
268
269 // Highlight in the middle - first
270 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
271 menuItem.highlight("ren");
272 expect(menuItem.element().innerHTML).toEqual("<div><h1>Co<mark>reN</mark>LP</h1><h2>co<mark>ren</mark>lp/</h2><h3>This is my Example</h3></div>");
273
274 plain = "<div><h1>CoreNLP</h1><h2>corenlp/</h2><h3>This is my Example</h3></div>"
275
276 menuItem.lowlight();
277 expect(menuItem.element().innerHTML).toEqual(plain);
278
279 // Highlight in the middle - second
280 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
281 menuItem.highlight("ampl");
282 expect(menuItem.element().innerHTML).toEqual("<div><h1>CoreNLP</h1><h2>corenlp/</h2><h3>This is my Ex<mark>ampl</mark>e</h3></div>");
283
284 menuItem.lowlight();
285 expect(menuItem.element().innerHTML).toEqual(plain);
286
287 // Highlight in the middle - both
288 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
289 menuItem.highlight("e");
290 expect(menuItem.element().innerHTML).toEqual("<div><h1>Cor<mark>e</mark>NLP</h1><h2>cor<mark>e</mark>nlp/</h2><h3>This is my <mark>E</mark>xampl<mark>e</mark></h3></div>");
291
292 menuItem.lowlight();
293 expect(menuItem.element().innerHTML).toEqual(plain);
294
295 // Highlight in the end - second
296 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
297 menuItem.highlight("le");
298 expect(menuItem.element().innerHTML).toEqual("<div><h1>CoreNLP</h1><h2>corenlp/</h2><h3>This is my Examp<mark>le</mark></h3></div>");
299
300 menuItem.lowlight();
301 expect(menuItem.element().innerHTML).toEqual(plain);
302
303 // Highlight at the beginning - second
304 menuItem = KorAP.ComplexMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
305 menuItem.highlight("this");
306 expect(menuItem.element().innerHTML).toEqual("<div><h1>CoreNLP</h1><h2>corenlp/</h2><h3><mark>This</mark> is my Example</h3></div>");
307
308 menuItem.lowlight();
309 expect(menuItem.element().innerHTML).toEqual(plain);
310 });
Nils Diewaldfda29d92015-01-22 17:28:01 +0000311});
312
313
314describe('KorAP.Menu', function () {
Nils Diewald2fe12e12015-03-06 16:47:06 +0000315 var list = [
316 ["Constituency", "c=", "Example 1"],
317 ["Lemma", "l="],
318 ["Morphology", "m=", "Example 2"],
319 ["Part-of-Speech", "p="],
320 ["Syntax", "syn="]
321 ];
322
Nils Diewaldfda29d92015-01-22 17:28:01 +0000323 it('should be initializable', function () {
Nils Diewald86dad5b2015-01-28 15:09:07 +0000324 var list = [
325 ["Constituency"],
326 ["Lemma"],
327 ["Morphology"],
328 ["Part-of-Speech"],
329 ["Syntax"]
330 ];
Nils Diewaldfda29d92015-01-22 17:28:01 +0000331
Nils Diewald86dad5b2015-01-28 15:09:07 +0000332 var menu = KorAP.OwnMenu.create(list);
333 expect(menu.itemClass()).toEqual(KorAP.OwnMenuItem);
334 expect(menu.element().nodeName).toEqual('UL');
335 expect(menu.element().style.opacity).toEqual("0");
336 expect(menu.limit()).toEqual(8);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000337
Nils Diewald86dad5b2015-01-28 15:09:07 +0000338 menu.limit(9);
339 expect(menu.limit()).toEqual(9);
340
341 menu.limit(8);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000342
343 // view
344 menu.show();
345
346 // First element in list
347 expect(menu.item(0).active()).toBe(true);
348 expect(menu.item(0).noMore()).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000349
Nils Diewaldfda29d92015-01-22 17:28:01 +0000350 // Middle element in list
351 expect(menu.item(2).active()).toBe(false);
352 expect(menu.item(2).noMore()).toBe(false);
353
354 // Last element in list
Nils Diewald86dad5b2015-01-28 15:09:07 +0000355 expect(menu.item(menu.length() - 1).active()).toBe(false);
356 expect(menu.item(menu.length() - 1).noMore()).toBe(true);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000357 });
358
359 it('should be visible', function () {
Nils Diewald86dad5b2015-01-28 15:09:07 +0000360 var menu = KorAP.HintMenu.create("cnx/", list);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000361 expect(menu.delete()).toBe(undefined);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000362 menu.limit(3);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000363
Nils Diewald59c02fc2015-03-07 01:29:09 +0000364 expect(menu.show()).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000365 expect(menu.element().firstChild.innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
366
367 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
368 expect(menu.element().childNodes[1].getAttribute("data-action")).toEqual("l=");
369 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
370 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000371
372 // Check boundaries
Nils Diewald86dad5b2015-01-28 15:09:07 +0000373 expect(menu.element().childNodes[0].classList.contains("no-more")).toBe(true);
374 expect(menu.element().childNodes[1].classList.contains("no-more")).toBe(false);
375 expect(menu.element().childNodes[2].classList.contains("no-more")).toBe(false);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000376 });
377
Nils Diewaldfda29d92015-01-22 17:28:01 +0000378 it('should be filterable', function () {
Nils Diewald86dad5b2015-01-28 15:09:07 +0000379 var menu = KorAP.HintMenu.create("cnx/", list);
380 menu.limit(3);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000381
Nils Diewald59c02fc2015-03-07 01:29:09 +0000382 expect(menu.show("o")).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000383 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
384 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
385 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
386 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000387
388 // Check boundaries
Nils Diewald86dad5b2015-01-28 15:09:07 +0000389 expect(menu.element().childNodes[0].classList.contains("no-more")).toBe(true);
390 expect(menu.element().childNodes[1].classList.contains("no-more")).toBe(false);
391 expect(menu.element().childNodes[2].classList.contains("no-more")).toBe(true);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000392
Nils Diewald86dad5b2015-01-28 15:09:07 +0000393 menu.limit(2);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000394
Nils Diewald59c02fc2015-03-07 01:29:09 +0000395 expect(menu.show("o")).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000396 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
397 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
398 expect(menu.element().childNodes[2]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000399
400 // Check boundaries
Nils Diewald86dad5b2015-01-28 15:09:07 +0000401 expect(menu.element().childNodes[0].classList.contains("no-more")).toBe(true);
402 expect(menu.element().childNodes[1].classList.contains("no-more")).toBe(false);
403 expect(menu.element().childNodes[2]).toBe(undefined);
404
Nils Diewald59c02fc2015-03-07 01:29:09 +0000405 expect(menu.show("e")).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000406 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
407 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
408 expect(menu.element().childNodes[2]).toBe(undefined);
409
410 menu.limit(5);
411
Nils Diewald59c02fc2015-03-07 01:29:09 +0000412 expect(menu.show("a")).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000413 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Ex<mark>a</mark>mple 1</span>");
414 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemm<mark>a</mark></strong>");
415 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Ex<mark>a</mark>mple 2</span>");
416 expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>P<mark>a</mark>rt-of-Speech</strong>");
417 expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Synt<mark>a</mark>x</strong>");
418 expect(menu.element().childNodes[5]).toBe(undefined);
419
Nils Diewaldfda29d92015-01-22 17:28:01 +0000420 });
421
Nils Diewald86dad5b2015-01-28 15:09:07 +0000422
Nils Diewaldfda29d92015-01-22 17:28:01 +0000423 it('should be nextable', function () {
Nils Diewald86dad5b2015-01-28 15:09:07 +0000424 var menu = KorAP.HintMenu.create("cnx/", list);
425
426 // Show only 3 items
427 menu.limit(3);
428
Nils Diewald59c02fc2015-03-07 01:29:09 +0000429 expect(menu.show()).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000430 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000431 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000432 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000433 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000434 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000435 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000436 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000437
438 // Activate next (1)
439 menu.next();
Nils Diewald86dad5b2015-01-28 15:09:07 +0000440 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000441 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000442 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000443 expect(menu.shownItem(1).active()).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000444 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000445 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000446 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000447
448 // Activate next (2)
449 menu.next();
Nils Diewald86dad5b2015-01-28 15:09:07 +0000450 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000451 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000452 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000453 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000454 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000455 expect(menu.shownItem(2).active()).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000456 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000457
458 // Activate next (3)
Nils Diewald2fe12e12015-03-06 16:47:06 +0000459 // scroll!
Nils Diewaldfda29d92015-01-22 17:28:01 +0000460 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000461 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Lemma</strong>");
462
Nils Diewaldfda29d92015-01-22 17:28:01 +0000463 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000464 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000465 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000466 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000467 expect(menu.shownItem(2).active()).toBe(true);
Nils Diewald86dad5b2015-01-28 15:09:07 +0000468 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000469
470 // Activate next (4)
471 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000472 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000473 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000474 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000475 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000476 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000477 expect(menu.shownItem(2).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000478 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000479
480 // Activate next (5) - ROLL
481 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000482 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000483 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000484 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000485 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000486 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000487 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000488 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000489
490 // Active next (6)
491 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000492 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000493 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000494 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000495 expect(menu.shownItem(1).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000496 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000497 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000498 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000499 });
500
Nils Diewaldfda29d92015-01-22 17:28:01 +0000501 it('should be prevable', function () {
Nils Diewald2fe12e12015-03-06 16:47:06 +0000502 var menu = KorAP.HintMenu.create("cnx/", list);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000503
Nils Diewald2fe12e12015-03-06 16:47:06 +0000504 menu.limit(3);
Nils Diewald59c02fc2015-03-07 01:29:09 +0000505 expect(menu.show()).toBe(true);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000506
Nils Diewald2fe12e12015-03-06 16:47:06 +0000507 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000508 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000509 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000510 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000511 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000512 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000513 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000514
515 // Activate prev (1) - roll to bottom
516 menu.prev();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000517 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000518 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000519 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000520 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000521 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000522 expect(menu.shownItem(2).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000523 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000524
525 // Activate prev (2)
526 menu.prev();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000527 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000528 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000529 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000530 expect(menu.shownItem(1).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000531 expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000532 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000533 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000534
535 // Activate prev (3)
536 menu.prev();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000537 expect(menu.shownItem(0).name()).toEqual("Morphology");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000538 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000539 expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000540 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000541 expect(menu.shownItem(2).name()).toEqual("Syntax");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000542 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000543 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000544
545 // Activate prev (4)
546 menu.prev();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000547 expect(menu.shownItem(0).name()).toEqual("Lemma");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000548 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000549 expect(menu.shownItem(1).name()).toEqual("Morphology");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000550 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000551 expect(menu.shownItem(2).name()).toEqual("Part-of-Speech");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000552 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000553 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000554
555 // Activate prev (5)
556 menu.prev();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000557 expect(menu.shownItem(0).name()).toEqual("Constituency");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000558 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000559 expect(menu.shownItem(1).name()).toEqual("Lemma");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000560 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000561 expect(menu.shownItem(2).name()).toEqual("Morphology");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000562 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000563 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000564
565 // Activate next (1)
566 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000567 expect(menu.shownItem(0).name()).toEqual("Constituency");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000568 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000569 expect(menu.shownItem(1).name()).toEqual("Lemma");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000570 expect(menu.shownItem(1).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000571 expect(menu.shownItem(2).name()).toEqual("Morphology");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000572 expect(menu.shownItem(2).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000573 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000574
575 // Activate prev (6)
576 menu.prev();
577
578 // Activate prev (7)
579 menu.prev();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000580 expect(menu.shownItem(0).name()).toEqual("Morphology");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000581 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000582 expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000583 expect(menu.shownItem(1).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000584 expect(menu.shownItem(2).name()).toEqual("Syntax");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000585 expect(menu.shownItem(2).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000586 expect(menu.element().childNodes[3]).toBe(undefined);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000587 });
588
Nils Diewaldfda29d92015-01-22 17:28:01 +0000589
Nils Diewald2fe12e12015-03-06 16:47:06 +0000590 it('should be navigatable and filterable (prefix = "o")', function () {
591 var menu = KorAP.HintMenu.create("cnx/", list);
592 menu.limit(2);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000593
Nils Diewald59c02fc2015-03-07 01:29:09 +0000594 expect(menu.show("o")).toBe(true);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000595
Nils Diewald2fe12e12015-03-06 16:47:06 +0000596 expect(menu.shownItem(0).name()).toEqual("Constituency");
597 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000598 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000599 expect(menu.shownItem(1).name()).toEqual("Morphology");
600 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000601 expect(menu.shownItem(1).active()).toBe(false);
602 expect(menu.shownItem(2)).toBe(undefined);
603
604 // Next (1)
605 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000606 expect(menu.shownItem(0).name()).toEqual("Constituency");
607 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000608 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000609 expect(menu.shownItem(1).name()).toEqual("Morphology");
610 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000611 expect(menu.shownItem(1).active()).toBe(true);
612 expect(menu.shownItem(2)).toBe(undefined);
613
Nils Diewaldfda29d92015-01-22 17:28:01 +0000614 // Next (2)
615 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000616 expect(menu.shownItem(0).name()).toEqual("Morphology");
617 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000618 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000619 expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
620 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000621 expect(menu.shownItem(1).active()).toBe(true);
622 expect(menu.shownItem(2)).toBe(undefined);
623
624 // Next (3)
625 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000626 expect(menu.shownItem(0).name()).toEqual("Constituency");
627 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000628 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000629 expect(menu.shownItem(1).name()).toEqual("Morphology");
630 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000631 expect(menu.shownItem(1).active()).toBe(false);
632 expect(menu.shownItem(2)).toBe(undefined);
633 });
634
Nils Diewald2fe12e12015-03-06 16:47:06 +0000635
Nils Diewaldfda29d92015-01-22 17:28:01 +0000636 it('should be navigatable and filterable (prefix = "ex", "e")', function () {
Nils Diewald2fe12e12015-03-06 16:47:06 +0000637 var menu = KorAP.HintMenu.create("cnx/", list);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000638
Nils Diewald2fe12e12015-03-06 16:47:06 +0000639 menu.limit(2);
Nils Diewald59c02fc2015-03-07 01:29:09 +0000640 expect(menu.show("ex")).toBe(true);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000641
Nils Diewald2fe12e12015-03-06 16:47:06 +0000642 expect(menu.shownItem(0).name()).toEqual("Constituency");
643 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000644 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000645 expect(menu.shownItem(1).name()).toEqual("Morphology");
646 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000647 expect(menu.shownItem(1).active()).toBe(false);
648 expect(menu.shownItem(2)).toBe(undefined);
649
650 // Next (1)
651 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000652 expect(menu.shownItem(0).name()).toEqual("Constituency");
653 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000654 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000655 expect(menu.shownItem(1).name()).toEqual("Morphology");
656 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000657 expect(menu.shownItem(1).active()).toBe(true);
658 expect(menu.shownItem(2)).toBe(undefined);
659
660 // Next (2)
661 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000662 expect(menu.shownItem(0).name()).toEqual("Constituency");
663 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000664 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000665 expect(menu.shownItem(1).name()).toEqual("Morphology");
666 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000667 expect(menu.shownItem(1).active()).toBe(false);
668 expect(menu.shownItem(2)).toBe(undefined);
669
670 // Reset limit
Nils Diewald2fe12e12015-03-06 16:47:06 +0000671 menu.limit(5);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000672
673 // Change show
Nils Diewald59c02fc2015-03-07 01:29:09 +0000674 expect(menu.show("e")).toBe(true);
Nils Diewaldfda29d92015-01-22 17:28:01 +0000675
Nils Diewald2fe12e12015-03-06 16:47:06 +0000676 expect(menu.shownItem(0).name()).toEqual("Constituency");
677 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000678 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000679 expect(menu.shownItem(1).name()).toEqual("Morphology");
680 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000681 expect(menu.shownItem(1).active()).toBe(false);
682 expect(menu.shownItem(2)).toBe(undefined);
683
684 // Next (1)
685 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000686 expect(menu.shownItem(0).name()).toEqual("Constituency");
687 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000688 expect(menu.shownItem(0).active()).toBe(false);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000689 expect(menu.shownItem(1).name()).toEqual("Morphology");
690 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000691 expect(menu.shownItem(1).active()).toBe(true);
692 expect(menu.shownItem(2)).toBe(undefined);
693
694 // Next (2)
695 menu.next();
Nils Diewald2fe12e12015-03-06 16:47:06 +0000696 expect(menu.shownItem(0).name()).toEqual("Constituency");
697 expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000698 expect(menu.shownItem(0).active()).toBe(true);
Nils Diewald2fe12e12015-03-06 16:47:06 +0000699 expect(menu.shownItem(1).name()).toEqual("Morphology");
700 expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
Nils Diewaldfda29d92015-01-22 17:28:01 +0000701 expect(menu.shownItem(1).active()).toBe(false);
702 expect(menu.shownItem(2)).toBe(undefined);
703 });
704});