blob: 554b61db167c20324a222117c0a2068542105a42 [file] [log] [blame]
Nils Diewald19ccee92014-12-08 11:30:08 +00001function emitKeyboardEvent (element, type, keyCode) {
2 // event type : keydown, keyup, keypress
3 // http://stackoverflow.com/questions/596481/simulate-javascript-key-events
4 // http://stackoverflow.com/questions/961532/firing-a-keyboard-event-in-javascript
5 var keyboardEvent = document.createEvent("KeyboardEvent");
6 var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ?
7 "initKeyboardEvent" : "initKeyEvent";
Nils Diewald19ccee92014-12-08 11:30:08 +00008 keyboardEvent[initMethod](
9 type,
Akron308db382016-05-30 22:34:07 +020010 true, // bubbles
11 true, // cancelable
12 window, // viewArg: should be window
13 false, // ctrlKeyArg
14 false, // altKeyArg
15 false, // shiftKeyArg
16 false, // metaKeyArg
Nils Diewald19ccee92014-12-08 11:30:08 +000017 keyCode, // keyCodeArg : unsigned long the virtual key code, else 0
Akron308db382016-05-30 22:34:07 +020018 0 // charCodeArgs : unsigned long the Unicode character
19 // associated with the depressed key, else 0
Nils Diewald19ccee92014-12-08 11:30:08 +000020 );
Nils Diewald19ccee92014-12-08 11:30:08 +000021 element.dispatchEvent(keyboardEvent);
22};
23
24
Nils Diewald7c8ced22015-04-15 19:21:00 +000025define(['hint'], function () {
Nils Diewald5c5a7472015-04-02 22:13:38 +000026
Nils Diewald7c8ced22015-04-15 19:21:00 +000027 var hintClass = require("hint");
28 var inputClass = require("hint/input");
29 var contextClass = require("hint/contextanalyzer");
30 var menuClass = require("hint/menu");
31 var menuItemClass = require("hint/item");
Nils Diewald5c5a7472015-04-02 22:13:38 +000032
Nils Diewald7c8ced22015-04-15 19:21:00 +000033 describe('KorAP.InputField', function () {
34 var input;
Nils Diewald1c546922015-04-13 01:56:19 +000035
Nils Diewald7c8ced22015-04-15 19:21:00 +000036 beforeEach(function () {
37 input = document.createElement("input");
38 input.setAttribute('type', "text");
39 input.setAttribute("value", "abcdefghijklmno");
40 input.style.position = 'absolute';
41 document.getElementsByTagName('body')[0].appendChild(input);
42 input.style.top = "20px";
43 input.style.left = "30px";
44 input.focus();
45 input.selectionStart = 5;
Nils Diewald5c5a7472015-04-02 22:13:38 +000046 });
47
Nils Diewald7c8ced22015-04-15 19:21:00 +000048 afterEach(function () {
49 document.getElementsByTagName("body")[0].removeChild(
50 input
51 );
52 });
Nils Diewald5c5a7472015-04-02 22:13:38 +000053
Nils Diewald7c8ced22015-04-15 19:21:00 +000054 afterAll(function () {
55 try {
56 document.getElementsByTagName("body")[0].removeChild(
57 document.getElementById("searchMirror")
58 );
59 }
60 catch (e) {};
61 });
Nils Diewald19ccee92014-12-08 11:30:08 +000062
Nils Diewald7c8ced22015-04-15 19:21:00 +000063 it('should be initializable', function () {
64 // Supports: context, searchField
65 var inputField = inputClass.create(input);
66 expect(inputField._element).not.toBe(undefined);
67 });
Nils Diewald19ccee92014-12-08 11:30:08 +000068
Nils Diewald7c8ced22015-04-15 19:21:00 +000069 it('should have text', function () {
70 expect(input.value).toEqual('abcdefghijklmno');
71 var inputField = inputClass.create(input);
Nils Diewald19ccee92014-12-08 11:30:08 +000072
Nils Diewald7c8ced22015-04-15 19:21:00 +000073 expect(inputField.value()).toEqual("abcdefghijklmno");
Nils Diewald19ccee92014-12-08 11:30:08 +000074
Nils Diewald7c8ced22015-04-15 19:21:00 +000075 expect(input.selectionStart).toEqual(5);
76 expect(inputField.element().selectionStart).toEqual(5);
Nils Diewald7148c6f2015-05-04 15:07:53 +000077 expect(inputField._split()[0]).toEqual("abcde");
78 expect(inputField._split()[1]).toEqual("fghijklmno");
Nils Diewald19ccee92014-12-08 11:30:08 +000079
Nils Diewald7c8ced22015-04-15 19:21:00 +000080 inputField.insert("xyz");
81 expect(inputField.value()).toEqual('abcdexyzfghijklmno');
Nils Diewald7148c6f2015-05-04 15:07:53 +000082 expect(inputField._split()[0]).toEqual("abcdexyz");
83 expect(inputField._split()[1]).toEqual("fghijklmno");
Nils Diewald7c8ced22015-04-15 19:21:00 +000084 });
Nils Diewald19ccee92014-12-08 11:30:08 +000085
Nils Diewald7c8ced22015-04-15 19:21:00 +000086 it('should be correctly positioned', function () {
87 expect(input.value).toEqual('abcdefghijklmno');
88 var inputField = inputClass.create(input);
89 document.getElementsByTagName("body")[0].appendChild(input);
90 inputField.reposition();
91 expect(input.style.left).toEqual("30px");
92 expect(inputField.mirror().style.left.match(/^(\d+)px$/)[1]).toBeGreaterThan(29);
93 expect(inputField.mirror().style.top.match(/^(\d+)px$/)[1]).toBeGreaterThan(20);
94 });
Nils Diewald19ccee92014-12-08 11:30:08 +000095
Nils Diewald7c8ced22015-04-15 19:21:00 +000096 it('should have a correct context', function () {
97 expect(input.value).toEqual('abcdefghijklmno');
98 var inputField = inputClass.create(input);
99 expect(inputField.value()).toEqual("abcdefghijklmno");
100 expect(inputField.element().selectionStart).toEqual(5);
Nils Diewald7148c6f2015-05-04 15:07:53 +0000101 expect(inputField._split()[0]).toEqual("abcde");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000102 expect(inputField.context()).toEqual("abcde");
103 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000104
Nils Diewald7c8ced22015-04-15 19:21:00 +0000105 /*
106 it('should be correctly triggerable', function () {
107 // https://developer.mozilla.org/samples/domref/dispatchEvent.html
108 var hint = KorAP.Hint.create({ "inputField" : input });
109 emitKeyboardEvent(hint.inputField.element, "keypress", 20);
110 });
111 */
Nils Diewald19ccee92014-12-08 11:30:08 +0000112 });
113
Nils Diewald1c546922015-04-13 01:56:19 +0000114
Nils Diewald7c8ced22015-04-15 19:21:00 +0000115 describe('KorAP.ContextAnalyzer', function () {
116 it('should be initializable', function () {
117 var analyzer = contextClass.create(")");
118 expect(analyzer).toBe(undefined);
119 analyzer = contextClass.create(".+?");
120 expect(analyzer).not.toBe(undefined);
121 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000122
Nils Diewald7c8ced22015-04-15 19:21:00 +0000123 it('should check correctly', function () {
124 analyzer = contextClass.create(KorAP.context);
125 expect(analyzer.test("cnx/]cnx/c=")).toEqual("cnx/c=");
126 expect(analyzer.test("cnx/c=")).toEqual("cnx/c=");
127 expect(analyzer.test("cnx/c=np mate/m=mood:")).toEqual("mate/m=mood:");
128 expect(analyzer.test("impcnx/")).toEqual("impcnx/");
129 expect(analyzer.test("cnx/c=npcnx/")).toEqual("npcnx/");
130 expect(analyzer.test("mate/m=degree:pos corenlp/ne_dewac_175m_600="))
131 .toEqual("corenlp/ne_dewac_175m_600=");
Akron113cc1a2016-01-22 21:17:57 +0100132 expect(analyzer.test("corenlp/")).toEqual("corenlp/");
133 expect(analyzer.test("corenlp/c=")).toEqual("corenlp/c=");
134 expect(analyzer.test("corenlp/c=PP-")).toEqual("corenlp/c=PP-");
135 expect(analyzer.test("corenlp/c=XY-")).toEqual("corenlp/c=XY-");
Akroncff9bac2016-01-25 21:39:38 +0100136 expect(analyzer.test("sgbr/l=")).toEqual("sgbr/l=");
137 expect(analyzer.test("sgbr/lv=")).toEqual("sgbr/lv=");
138 expect(analyzer.test("sgbr/p=")).toEqual("sgbr/p=");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000139 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000140 });
141
Nils Diewald19ccee92014-12-08 11:30:08 +0000142
Nils Diewald7c8ced22015-04-15 19:21:00 +0000143 describe('KorAP.Hint', function () {
144 KorAP.hintArray = {
145 "corenlp/" : [
146 ["Named Entity", "ne=" , "Combined"],
147 ["Named Entity", "ne_dewac_175m_600=" , "ne_dewac_175m_600"],
148 ["Named Entity", "ne_hgc_175m_600=", "ne_hgc_175m_600"]
149 ]
150 };
Nils Diewald19ccee92014-12-08 11:30:08 +0000151
Nils Diewald7c8ced22015-04-15 19:21:00 +0000152 beforeEach(function () {
153 input = document.createElement("input");
154 input.setAttribute("type", "text");
155 input.setAttribute("value", "abcdefghijklmno");
156 input.style.position = 'absolute';
157 input.style.top = "20px";
158 input.style.left = "30px";
159 input.focus();
160 input.selectionStart = 5;
161 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000162
Nils Diewald7c8ced22015-04-15 19:21:00 +0000163 it('should be initializable', function () {
164 // Supports: context, searchField
165 var hint = hintClass.create({
166 inputField : input
167 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000168
Nils Diewald7c8ced22015-04-15 19:21:00 +0000169 expect(hint).toBeTruthy();
170 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000171 });
172
Nils Diewald7c8ced22015-04-15 19:21:00 +0000173 describe('KorAP.HintMenuItem', function () {
174 it('should be initializable', function () {
175 expect(
176 function() { menuItemClass.create([]) }
177 ).toThrow(new Error("Missing parameters"));
Nils Diewald19ccee92014-12-08 11:30:08 +0000178
Nils Diewald7c8ced22015-04-15 19:21:00 +0000179 expect(
180 function() { menuItemClass.create(['CoreNLP']) }
181 ).toThrow(new Error("Missing parameters"));
Nils Diewald19ccee92014-12-08 11:30:08 +0000182
Nils Diewald7c8ced22015-04-15 19:21:00 +0000183 var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
184 expect(menuItem.name()).toEqual('CoreNLP');
185 expect(menuItem.action()).toEqual('corenlp/');
186 expect(menuItem.desc()).toBeUndefined();
Nils Diewald19ccee92014-12-08 11:30:08 +0000187
Nils Diewald7c8ced22015-04-15 19:21:00 +0000188 menuItem = menuItemClass.create(
189 ['CoreNLP', 'corenlp/', 'It\'s funny']
190 );
191 expect(menuItem.name()).toEqual('CoreNLP');
192 expect(menuItem.action()).toEqual('corenlp/');
193 expect(menuItem.desc()).not.toBeUndefined();
194 expect(menuItem.desc()).toEqual('It\'s funny');
195 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000196
Nils Diewald7c8ced22015-04-15 19:21:00 +0000197 it('should have an element', function () {
198 var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
199 expect(menuItem.element()).not.toBe(undefined);
200 expect(menuItem.element().nodeName).toEqual("LI");
Nils Diewald19ccee92014-12-08 11:30:08 +0000201
Nils Diewald7c8ced22015-04-15 19:21:00 +0000202 var title = menuItem.element().firstChild;
203 expect(title.nodeName).toEqual("SPAN");
204 expect(title.firstChild.nodeType).toEqual(3);
205 expect(title.firstChild.nodeValue).toEqual("CoreNLP");
206 expect(menuItem.element().childNodes[0]).not.toBe(undefined);
207 expect(menuItem.element().childNodes[1]).toBe(undefined);
Nils Diewald19ccee92014-12-08 11:30:08 +0000208
Nils Diewald7c8ced22015-04-15 19:21:00 +0000209 menuItem = menuItemClass.create(
210 ['CoreNLP', 'corenlp/', 'my DescRiption']
211 );
212 expect(menuItem.element()).not.toBe(undefined);
213 expect(menuItem.element().nodeName).toEqual("LI");
Nils Diewald19ccee92014-12-08 11:30:08 +0000214
Nils Diewald7c8ced22015-04-15 19:21:00 +0000215 title = menuItem.element().firstChild;
216 expect(title.nodeName).toEqual("SPAN");
217 expect(title.firstChild.nodeType).toEqual(3); // TextNode
218 expect(title.firstChild.nodeValue).toEqual("CoreNLP");
Nils Diewald19ccee92014-12-08 11:30:08 +0000219
Nils Diewald7c8ced22015-04-15 19:21:00 +0000220 expect(menuItem.element().childNodes[0]).not.toBe(undefined);
221 expect(menuItem.element().childNodes[1]).not.toBe(undefined);
Nils Diewald19ccee92014-12-08 11:30:08 +0000222
Nils Diewald7c8ced22015-04-15 19:21:00 +0000223 var desc = menuItem.element().lastChild;
224 expect(desc.nodeName).toEqual("SPAN");
225 expect(desc.firstChild.nodeType).toEqual(3); // TextNode
226 expect(desc.firstChild.nodeValue).toEqual("my DescRiption");
227 });
Nils Diewald1c546922015-04-13 01:56:19 +0000228
Nils Diewald19ccee92014-12-08 11:30:08 +0000229
Nils Diewald7c8ced22015-04-15 19:21:00 +0000230 it('should be activatable and deactivateable by class', function () {
231 var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
232 expect(menuItem.active()).toBe(false);
233 expect(menuItem.element().getAttribute("class")).toBe(null);
234 menuItem.active(true);
235 expect(menuItem.active()).toBe(true);
236 expect(menuItem.element().getAttribute("class")).toEqual("active");
237 menuItem.active(false); // Is active
238 expect(menuItem.active()).toBe(false);
239 expect(menuItem.element().getAttribute("class")).toEqual("");
240 menuItem.active(true);
241 expect(menuItem.active()).toBe(true);
242 expect(menuItem.element().getAttribute("class")).toEqual("active");
Nils Diewald19ccee92014-12-08 11:30:08 +0000243
Nils Diewald7c8ced22015-04-15 19:21:00 +0000244 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
245 expect(menuItem.active()).toBe(false);
246 expect(menuItem.element().getAttribute("class")).toBe(null);
247 menuItem.active(false); // Is not active
248 expect(menuItem.active()).toBe(false);
249 expect(menuItem.element().getAttribute("class")).toBe(null);
250 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000251
Nils Diewald7c8ced22015-04-15 19:21:00 +0000252 it('should be set to boundary', function () {
253 var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
254 expect(menuItem.active()).toBe(false);
255 expect(menuItem.element().getAttribute("class")).toBe(null);
Nils Diewald19ccee92014-12-08 11:30:08 +0000256
Nils Diewald7c8ced22015-04-15 19:21:00 +0000257 // Set active
258 menuItem.active(true);
259 expect(menuItem.active()).toBe(true);
260 expect(menuItem.noMore()).toBe(false);
261 expect(menuItem.element().getAttribute("class")).toEqual("active");
Nils Diewald19ccee92014-12-08 11:30:08 +0000262
Nils Diewald7c8ced22015-04-15 19:21:00 +0000263 // Set no more
264 menuItem.noMore(true);
265 expect(menuItem.active()).toBe(true);
266 expect(menuItem.noMore()).toBe(true);
267 expect(menuItem.element().getAttribute("class")).toEqual("active no-more");
Nils Diewald1c546922015-04-13 01:56:19 +0000268
Nils Diewald7c8ced22015-04-15 19:21:00 +0000269 // No no more
270 menuItem.noMore(false);
271 expect(menuItem.active()).toBe(true);
272 expect(menuItem.noMore()).toBe(false);
273 expect(menuItem.element().getAttribute("class")).toEqual("active");
Nils Diewald1c546922015-04-13 01:56:19 +0000274
Nils Diewald7c8ced22015-04-15 19:21:00 +0000275 // Set no more, deactivate
276 menuItem.noMore(true);
277 menuItem.active(false);
278 expect(menuItem.active()).toBe(false);
279 expect(menuItem.noMore()).toBe(true);
280 expect(menuItem.element().getAttribute("class")).toEqual("no-more");
Nils Diewald19ccee92014-12-08 11:30:08 +0000281
Nils Diewald7c8ced22015-04-15 19:21:00 +0000282 // Set active
283 menuItem.active(true);
284 expect(menuItem.active()).toBe(true);
285 expect(menuItem.noMore()).toBe(true);
286 expect(menuItem.element().getAttribute("class")).toEqual("no-more active");
287 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000288
Nils Diewald7c8ced22015-04-15 19:21:00 +0000289 it('should be highlightable', function () {
290 // Highlight in the middle
291 var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
292 menuItem.highlight("ren");
293 expect(menuItem.element().innerHTML).toEqual("<span>Co<mark>reN</mark>LP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000294
Nils Diewald7c8ced22015-04-15 19:21:00 +0000295 menuItem.lowlight();
296 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000297
Nils Diewald7c8ced22015-04-15 19:21:00 +0000298 // Starting highlight
299 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
300 menuItem.highlight("cor");
301 expect(menuItem.element().innerHTML).toEqual("<span><mark>Cor</mark>eNLP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000302
Nils Diewald7c8ced22015-04-15 19:21:00 +0000303 menuItem.lowlight();
304 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
305
306 // Starting highlight - short
307 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
308 menuItem.highlight("c");
309 expect(menuItem.element().innerHTML).toEqual("<span><mark>C</mark>oreNLP</span>");
310
311 menuItem.lowlight();
312 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
313
314 // Highlight at the end
315 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
316 menuItem.highlight("nlp");
317 expect(menuItem.element().innerHTML).toEqual("<span>Core<mark>NLP</mark></span>");
318
319 menuItem.lowlight();
320 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
321
322 // Highlight at the end - short
323 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
324 menuItem.highlight("p");
325 expect(menuItem.element().innerHTML).toEqual("<span>CoreNL<mark>P</mark></span>");
326
327 menuItem.lowlight();
328 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
329
330 // No highlight
331 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
332 menuItem.highlight("xp");
333 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
334
335 menuItem.lowlight();
336 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
337
338 // Highlight in the middle - first
339 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']);
340
341 menuItem.highlight("ren");
342 expect(menuItem.element().innerHTML).toEqual("<span>Co<mark>reN</mark>LP</span><span class=\"desc\">This is my Example</span>");
343
344 menuItem.lowlight();
345 expect(menuItem.element().innerHTML).toEqual('<span>CoreNLP</span><span class="desc">This is my Example</span>');
346
347 // Highlight in the middle - second
348 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']);
349 menuItem.highlight("ampl");
350 expect(menuItem.element().innerHTML).toEqual('<span>CoreNLP</span><span class="desc">This is my Ex<mark>ampl</mark>e</span>');
351
352 menuItem.lowlight();
353 expect(menuItem.element().innerHTML).toEqual('<span>CoreNLP</span><span class="desc">This is my Example</span>');
354
355 // Highlight in the middle - both
356 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']);
357
358 menuItem.highlight("e");
359 expect(menuItem.element().innerHTML).toEqual('<span>Cor<mark>e</mark>NLP</span><span class="desc">This is my <mark>E</mark>xampl<mark>e</mark></span>');
360
361 menuItem.lowlight();
362 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\">This is my Example</span>");
363
364 // Highlight in the end - second
365 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']);
366 menuItem.highlight("le");
367 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\">This is my Examp<mark>le</mark></span>");
368
369 menuItem.lowlight();
370 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\">This is my Example</span>");
371
372 // Highlight at the beginning - second
373 menuItem = menuItemClass.create(['CoreNLP', 'corenlp/', 'This is my Example']);
374 menuItem.highlight("this");
375 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\"><mark>This</mark> is my Example</span>");
376
377 menuItem.lowlight();
378 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span class=\"desc\">This is my Example</span>");
Akron6ed13992016-05-23 18:06:05 +0200379
Nils Diewald7c8ced22015-04-15 19:21:00 +0000380 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000381 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000382
Nils Diewald7c8ced22015-04-15 19:21:00 +0000383 describe('KorAP.HintMenu', function () {
Nils Diewald19ccee92014-12-08 11:30:08 +0000384
Nils Diewald7c8ced22015-04-15 19:21:00 +0000385 var list = [
386 ["Constituency", "c=", "Example 1"],
387 ["Lemma", "l="],
388 ["Morphology", "m=", "Example 2"],
389 ["Part-of-Speech", "p="],
390 ["Syntax", "syn="]
391 ];
Nils Diewald19ccee92014-12-08 11:30:08 +0000392
Nils Diewald7c8ced22015-04-15 19:21:00 +0000393 it('should be initializable', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000394 var menu = menuClass.create(null, "cnx/", list);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000395 expect(menu.element().nodeName).toEqual('UL');
396 expect(menu.element().style.opacity).toEqual("0");
Nils Diewald19ccee92014-12-08 11:30:08 +0000397
Nils Diewald7c8ced22015-04-15 19:21:00 +0000398 menu.limit(8);
Nils Diewald19ccee92014-12-08 11:30:08 +0000399
Nils Diewald7c8ced22015-04-15 19:21:00 +0000400 // view
401 menu.show();
Akron6ed13992016-05-23 18:06:05 +0200402 expect(menu.prefix()).toBe('');
Nils Diewald19ccee92014-12-08 11:30:08 +0000403
Nils Diewald7c8ced22015-04-15 19:21:00 +0000404 // First element in list
405 expect(menu.item(0).active()).toBe(true);
406 expect(menu.item(0).noMore()).toBe(true);
407
408 // Middle element in list
409 expect(menu.item(2).active()).toBe(false);
410 expect(menu.item(2).noMore()).toBe(false);
Nils Diewald19ccee92014-12-08 11:30:08 +0000411
Nils Diewald7c8ced22015-04-15 19:21:00 +0000412 // Last element in list
413 expect(menu.item(menu.length() - 1).active()).toBe(false);
414 expect(menu.item(menu.length() - 1).noMore()).toBe(true);
Akron6ed13992016-05-23 18:06:05 +0200415
416 expect(menu.shownItem(0).active()).toBeTruthy();
417 expect(menu.shownItem(0).lcField()).toEqual(' constituency example 1');
418 expect(menu.shownItem(1).lcField()).toEqual(' lemma');
419 expect(menu.shownItem(2).lcField()).toEqual(' morphology example 2');
420
421 menu.next();
422 expect(menu.shownItem(1).active()).toBeTruthy();
423
424 menu.next();
425 expect(menu.shownItem(2).active()).toBeTruthy();
426
Nils Diewald7c8ced22015-04-15 19:21:00 +0000427 });
Nils Diewald19ccee92014-12-08 11:30:08 +0000428 });
429});