blob: 45457b4c710dff7390d40ab9c14a49af985ac836 [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";
8
9 keyboardEvent[initMethod](
10 type,
11 true, // bubbles
12 true, // cancelable
13 window, // viewArg: should be window
14 false, // ctrlKeyArg
15 false, // altKeyArg
16 false, // shiftKeyArg
17 false, // metaKeyArg
18 keyCode, // keyCodeArg : unsigned long the virtual key code, else 0
19 0 // charCodeArgs : unsigned long the Unicode character
20 // associated with the depressed key, else 0
21 );
22
23 element.dispatchEvent(keyboardEvent);
24};
25
26
Nils Diewald5c5a7472015-04-02 22:13:38 +000027describe('KorAP.InputField', function () {
28 var input;
29
30 beforeEach(function () {
31 input = document.createElement("input");
Nils Diewald1c546922015-04-13 01:56:19 +000032 input.setAttribute('type', "text");
Nils Diewald5c5a7472015-04-02 22:13:38 +000033 input.setAttribute("value", "abcdefghijklmno");
34 input.style.position = 'absolute';
Nils Diewald1c546922015-04-13 01:56:19 +000035 document.getElementsByTagName('body')[0].appendChild(input);
Nils Diewald5c5a7472015-04-02 22:13:38 +000036 input.style.top = "20px";
37 input.style.left = "30px";
38 input.focus();
39 input.selectionStart = 5;
40 });
41
Nils Diewald1c546922015-04-13 01:56:19 +000042 afterEach(function () {
43 document.getElementsByTagName("body")[0].removeChild(
44 input
45 );
46 });
47
Nils Diewald5c5a7472015-04-02 22:13:38 +000048 afterAll(function () {
49 try {
Nils Diewald5c5a7472015-04-02 22:13:38 +000050 document.getElementsByTagName("body")[0].removeChild(
51 document.getElementById("searchMirror")
52 );
53 }
54 catch (e) {};
55 });
56
57 it('should be initializable', function () {
58 // Supports: context, searchField
59 var inputField = KorAP.InputField.create(input);
60 expect(inputField._element).not.toBe(undefined);
61 });
62
63 it('should have text', function () {
64 expect(input.value).toEqual('abcdefghijklmno');
65 var inputField = KorAP.InputField.create(input);
66
67 expect(inputField.value()).toEqual("abcdefghijklmno");
68
Nils Diewald1c546922015-04-13 01:56:19 +000069 expect(input.selectionStart).toEqual(5);
Nils Diewald5c5a7472015-04-02 22:13:38 +000070 expect(inputField.element().selectionStart).toEqual(5);
71 expect(inputField.split()[0]).toEqual("abcde");
72 expect(inputField.split()[1]).toEqual("fghijklmno");
73
74 inputField.insert("xyz");
75 expect(inputField.value()).toEqual('abcdexyzfghijklmno');
76 expect(inputField.split()[0]).toEqual("abcdexyz");
77 expect(inputField.split()[1]).toEqual("fghijklmno");
78 });
79
80 it('should be correctly positioned', function () {
81 expect(input.value).toEqual('abcdefghijklmno');
82 var inputField = KorAP.InputField.create(input);
83 document.getElementsByTagName("body")[0].appendChild(input);
84 inputField.reposition();
Nils Diewald1c546922015-04-13 01:56:19 +000085 expect(input.style.left).toEqual("30px");
86 expect(inputField.mirror().style.left.match(/^(\d+)px$/)[1]).toBeGreaterThan(29);
Nils Diewald5c5a7472015-04-02 22:13:38 +000087 expect(inputField.mirror().style.top.match(/^(\d+)px$/)[1]).toBeGreaterThan(20);
88 });
89
90 it('should have a correct context', function () {
91 expect(input.value).toEqual('abcdefghijklmno');
92 var inputField = KorAP.InputField.create(input);
93
94 expect(inputField.value()).toEqual("abcdefghijklmno");
95
96 expect(inputField.element().selectionStart).toEqual(5);
97 expect(inputField.split()[0]).toEqual("abcde");
98 expect(inputField.context()).toEqual("abcde");
99 });
100
101/*
102 it('should be correctly triggerable', function () {
103 // https://developer.mozilla.org/samples/domref/dispatchEvent.html
104 var hint = KorAP.Hint.create({ "inputField" : input });
105 emitKeyboardEvent(hint.inputField.element, "keypress", 20);
106 });
107*/
108});
109
110
111describe('KorAP.ContextAnalyzer', function () {
112 it('should be initializable', function () {
113 var analyzer = KorAP.ContextAnalyzer.create(")");
114 expect(analyzer).toBe(undefined);
115
116 analyzer = KorAP.ContextAnalyzer.create(".+?");
117 expect(analyzer).not.toBe(undefined);
118
119 });
120
121 it('should check correctly', function () {
122 analyzer = KorAP.ContextAnalyzer.create(KorAP.context);
123 expect(analyzer.test("cnx/]cnx/c=")).toEqual("cnx/c=");
124 expect(analyzer.test("cnx/c=")).toEqual("cnx/c=");
125 expect(analyzer.test("cnx/c=np mate/m=mood:")).toEqual("mate/m=mood:");
126 expect(analyzer.test("impcnx/")).toEqual("impcnx/");
127 expect(analyzer.test("cnx/c=npcnx/")).toEqual("npcnx/");
128 expect(analyzer.test("mate/m=degree:pos corenlp/ne_dewac_175m_600="))
129 .toEqual("corenlp/ne_dewac_175m_600=");
130 });
131});
132
133
134describe('KorAP.Hint', function () {
135 KorAP.hintArray = {
136 "corenlp/" : [
137 ["Named Entity", "ne=" , "Combined"],
138 ["Named Entity", "ne_dewac_175m_600=" , "ne_dewac_175m_600"],
139 ["Named Entity", "ne_hgc_175m_600=", "ne_hgc_175m_600"]
140 ]
141 };
142
143 beforeEach(function () {
144 input = document.createElement("input");
145 input.setAttribute("type", "text");
146 input.setAttribute("value", "abcdefghijklmno");
147 input.style.position = 'absolute';
148 input.style.top = "20px";
149 input.style.left = "30px";
150 input.focus();
151 input.selectionStart = 5;
152 });
153
154 it('should be initializable', function () {
155 // Supports: context, searchField
156 var hint = KorAP.Hint.create({
157 inputField : input
158 });
159
160 expect(hint).toBeTruthy();
161 });
162});
163
Nils Diewald1c546922015-04-13 01:56:19 +0000164describe('KorAP.HintMenuItem', function () {
Nils Diewald19ccee92014-12-08 11:30:08 +0000165 it('should be initializable', function () {
Nils Diewald19ccee92014-12-08 11:30:08 +0000166 expect(
Nils Diewald1c546922015-04-13 01:56:19 +0000167 function() { KorAP.HintMenuItem.create([]) }
Nils Diewald19ccee92014-12-08 11:30:08 +0000168 ).toThrow(new Error("Missing parameters"));
169
170 expect(
Nils Diewald1c546922015-04-13 01:56:19 +0000171 function() { KorAP.HintMenuItem.create(['CoreNLP']) }
Nils Diewald19ccee92014-12-08 11:30:08 +0000172 ).toThrow(new Error("Missing parameters"));
173
Nils Diewald1c546922015-04-13 01:56:19 +0000174 var menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
175 expect(menuItem.name()).toEqual('CoreNLP');
176 expect(menuItem.action()).toEqual('corenlp/');
177 expect(menuItem.desc()).toBeUndefined();
Nils Diewald19ccee92014-12-08 11:30:08 +0000178
Nils Diewald1c546922015-04-13 01:56:19 +0000179 menuItem = KorAP.HintMenuItem.create(
180 ['CoreNLP', 'corenlp/', 'It\'s funny']
181 );
182 expect(menuItem.name()).toEqual('CoreNLP');
183 expect(menuItem.action()).toEqual('corenlp/');
184 expect(menuItem.desc()).not.toBeUndefined();
185 expect(menuItem.desc()).toEqual('It\'s funny');
Nils Diewald19ccee92014-12-08 11:30:08 +0000186 });
187
188 it('should have an element', function () {
Nils Diewald1c546922015-04-13 01:56:19 +0000189 var menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
190 expect(menuItem.element()).not.toBe(undefined);
191 expect(menuItem.element().nodeName).toEqual("LI");
Nils Diewald19ccee92014-12-08 11:30:08 +0000192
Nils Diewald1c546922015-04-13 01:56:19 +0000193 var title = menuItem.element().firstChild;
194 expect(title.nodeName).toEqual("SPAN");
Nils Diewald19ccee92014-12-08 11:30:08 +0000195 expect(title.firstChild.nodeType).toEqual(3);
196 expect(title.firstChild.nodeValue).toEqual("CoreNLP");
Nils Diewald1c546922015-04-13 01:56:19 +0000197 expect(menuItem.element().childNodes[0]).not.toBe(undefined);
198 expect(menuItem.element().childNodes[1]).toBe(undefined);
Nils Diewald19ccee92014-12-08 11:30:08 +0000199
Nils Diewald1c546922015-04-13 01:56:19 +0000200 menuItem = KorAP.HintMenuItem.create(
201 ['CoreNLP', 'corenlp/', 'my DescRiption']
202 );
203 expect(menuItem.element()).not.toBe(undefined);
204 expect(menuItem.element().nodeName).toEqual("LI");
Nils Diewald19ccee92014-12-08 11:30:08 +0000205
Nils Diewald1c546922015-04-13 01:56:19 +0000206 title = menuItem.element().firstChild;
207 expect(title.nodeName).toEqual("SPAN");
Nils Diewald19ccee92014-12-08 11:30:08 +0000208 expect(title.firstChild.nodeType).toEqual(3); // TextNode
209 expect(title.firstChild.nodeValue).toEqual("CoreNLP");
210
Nils Diewald1c546922015-04-13 01:56:19 +0000211 expect(menuItem.element().childNodes[0]).not.toBe(undefined);
212 expect(menuItem.element().childNodes[1]).not.toBe(undefined);
Nils Diewald19ccee92014-12-08 11:30:08 +0000213
Nils Diewald1c546922015-04-13 01:56:19 +0000214 var desc = menuItem.element().lastChild;
Nils Diewald19ccee92014-12-08 11:30:08 +0000215 expect(desc.nodeName).toEqual("SPAN");
216 expect(desc.firstChild.nodeType).toEqual(3); // TextNode
217 expect(desc.firstChild.nodeValue).toEqual("my DescRiption");
Nils Diewald19ccee92014-12-08 11:30:08 +0000218 });
219
Nils Diewald1c546922015-04-13 01:56:19 +0000220
Nils Diewald19ccee92014-12-08 11:30:08 +0000221 it('should be activatable and deactivateable by class', function () {
Nils Diewald1c546922015-04-13 01:56:19 +0000222 var menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000223 expect(menuItem.active()).toBe(false);
Nils Diewald1c546922015-04-13 01:56:19 +0000224 expect(menuItem.element().getAttribute("class")).toBe(null);
Nils Diewald19ccee92014-12-08 11:30:08 +0000225 menuItem.active(true);
226 expect(menuItem.active()).toBe(true);
Nils Diewald1c546922015-04-13 01:56:19 +0000227 expect(menuItem.element().getAttribute("class")).toEqual("active");
Nils Diewald19ccee92014-12-08 11:30:08 +0000228 menuItem.active(false); // Is active
229 expect(menuItem.active()).toBe(false);
Nils Diewald1c546922015-04-13 01:56:19 +0000230 expect(menuItem.element().getAttribute("class")).toEqual("");
Nils Diewald19ccee92014-12-08 11:30:08 +0000231 menuItem.active(true);
232 expect(menuItem.active()).toBe(true);
Nils Diewald1c546922015-04-13 01:56:19 +0000233 expect(menuItem.element().getAttribute("class")).toEqual("active");
Nils Diewald19ccee92014-12-08 11:30:08 +0000234
Nils Diewald1c546922015-04-13 01:56:19 +0000235 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000236 expect(menuItem.active()).toBe(false);
Nils Diewald1c546922015-04-13 01:56:19 +0000237 expect(menuItem.element().getAttribute("class")).toBe(null);
Nils Diewald19ccee92014-12-08 11:30:08 +0000238 menuItem.active(false); // Is not active
239 expect(menuItem.active()).toBe(false);
Nils Diewald1c546922015-04-13 01:56:19 +0000240 expect(menuItem.element().getAttribute("class")).toBe(null);
Nils Diewald19ccee92014-12-08 11:30:08 +0000241 });
242
243 it('should be set to boundary', function () {
Nils Diewald1c546922015-04-13 01:56:19 +0000244 var menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000245 expect(menuItem.active()).toBe(false);
Nils Diewald1c546922015-04-13 01:56:19 +0000246 expect(menuItem.element().getAttribute("class")).toBe(null);
Nils Diewald19ccee92014-12-08 11:30:08 +0000247
248 // Set active
249 menuItem.active(true);
250 expect(menuItem.active()).toBe(true);
251 expect(menuItem.noMore()).toBe(false);
Nils Diewald1c546922015-04-13 01:56:19 +0000252 expect(menuItem.element().getAttribute("class")).toEqual("active");
Nils Diewald19ccee92014-12-08 11:30:08 +0000253
254 // Set no more
255 menuItem.noMore(true);
256 expect(menuItem.active()).toBe(true);
257 expect(menuItem.noMore()).toBe(true);
Nils Diewald1c546922015-04-13 01:56:19 +0000258 expect(menuItem.element().getAttribute("class")).toEqual("active no-more");
Nils Diewald19ccee92014-12-08 11:30:08 +0000259
260 // No no more
261 menuItem.noMore(false);
262 expect(menuItem.active()).toBe(true);
263 expect(menuItem.noMore()).toBe(false);
Nils Diewald1c546922015-04-13 01:56:19 +0000264 expect(menuItem.element().getAttribute("class")).toEqual("active");
Nils Diewald19ccee92014-12-08 11:30:08 +0000265
266 // Set no more, deactivate
267 menuItem.noMore(true);
268 menuItem.active(false);
269 expect(menuItem.active()).toBe(false);
270 expect(menuItem.noMore()).toBe(true);
Nils Diewald1c546922015-04-13 01:56:19 +0000271 expect(menuItem.element().getAttribute("class")).toEqual("no-more");
Nils Diewald19ccee92014-12-08 11:30:08 +0000272
273 // Set active
274 menuItem.active(true);
275 expect(menuItem.active()).toBe(true);
276 expect(menuItem.noMore()).toBe(true);
Nils Diewald1c546922015-04-13 01:56:19 +0000277 expect(menuItem.element().getAttribute("class")).toEqual("no-more active");
Nils Diewald19ccee92014-12-08 11:30:08 +0000278 });
279
Nils Diewald1c546922015-04-13 01:56:19 +0000280 xit('should be highlightable', function () {
Nils Diewald19ccee92014-12-08 11:30:08 +0000281 // Highlight in the middle
Nils Diewald1c546922015-04-13 01:56:19 +0000282 var menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000283 menuItem.highlight("ren");
Nils Diewald1c546922015-04-13 01:56:19 +0000284 expect(menuItem.element().innerHTML).toEqual("<span>Co<mark>reN</mark>LP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000285
286 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000287 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000288
289 // Starting highlight
Nils Diewald1c546922015-04-13 01:56:19 +0000290 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000291 menuItem.highlight("cor");
Nils Diewald1c546922015-04-13 01:56:19 +0000292 expect(menuItem.element().innerHTML).toEqual("<span><mark>Cor</mark>eNLP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000293
294 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000295 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
296/*
Nils Diewald19ccee92014-12-08 11:30:08 +0000297
298 // Starting highlight - short
Nils Diewald1c546922015-04-13 01:56:19 +0000299 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000300 menuItem.highlight("c");
Nils Diewald1c546922015-04-13 01:56:19 +0000301 expect(menuItem.element().innerHTML).toEqual("<span><mark>C</mark>oreNLP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000302
303 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000304 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000305
306 // Highlight at the end
Nils Diewald1c546922015-04-13 01:56:19 +0000307 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000308 menuItem.highlight("nlp");
Nils Diewald1c546922015-04-13 01:56:19 +0000309 expect(menuItem.element().innerHTML).toEqual("<span>Core<mark>NLP</mark></span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000310
311 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000312 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000313
314 // Highlight at the end - short
Nils Diewald1c546922015-04-13 01:56:19 +0000315 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000316 menuItem.highlight("p");
Nils Diewald1c546922015-04-13 01:56:19 +0000317 expect(menuItem.element().innerHTML).toEqual("<span>CoreNL<mark>P</mark></span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000318
319 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000320 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000321
322 // No highlight
Nils Diewald1c546922015-04-13 01:56:19 +0000323 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000324 menuItem.highlight("xp");
Nils Diewald1c546922015-04-13 01:56:19 +0000325 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000326
327 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000328 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span>");
329
Nils Diewald19ccee92014-12-08 11:30:08 +0000330
331 // Highlight in the middle - first
Nils Diewald1c546922015-04-13 01:56:19 +0000332 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000333 menuItem.highlight("ren");
Nils Diewald1c546922015-04-13 01:56:19 +0000334 expect(menuItem.element().innerHTML).toEqual("<span>Co<mark>reN</mark>LP</span><span class=\"desc\">This is my Example</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000335
336 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000337 expect(menuItem.element().innerHTML).toEqual('<span>CoreNLP</span><span class="desc">This is my Example</span>');
Nils Diewald19ccee92014-12-08 11:30:08 +0000338
339 // Highlight in the middle - second
Nils Diewald1c546922015-04-13 01:56:19 +0000340 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000341 menuItem.highlight("ampl");
Nils Diewald1c546922015-04-13 01:56:19 +0000342 expect(menuItem.element().innerHTML).toEqual('<span>CoreNLP</span><span class="desc">This is my Ex<mark>ampl</mark>e</span>');
Nils Diewald19ccee92014-12-08 11:30:08 +0000343
344 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000345 expect(menuItem.element().innerHTML).toEqual('<span>CoreNLP</span><span class="desc">This is my Example</span>');
Nils Diewald19ccee92014-12-08 11:30:08 +0000346
347 // Highlight in the middle - both
Nils Diewald1c546922015-04-13 01:56:19 +0000348 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
349
Nils Diewald19ccee92014-12-08 11:30:08 +0000350 menuItem.highlight("e");
Nils Diewald1c546922015-04-13 01:56:19 +0000351 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>');
352
Nils Diewald19ccee92014-12-08 11:30:08 +0000353
354 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000355 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span>This is my Example</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000356
357 // Highlight in the end - second
Nils Diewald1c546922015-04-13 01:56:19 +0000358 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000359 menuItem.highlight("le");
Nils Diewald1c546922015-04-13 01:56:19 +0000360 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span>This is my Examp<mark>le</mark></span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000361
362 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000363 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span>This is my Example</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000364
365 // Highlight at the beginning - second
Nils Diewald1c546922015-04-13 01:56:19 +0000366 menuItem = KorAP.HintMenuItem.create(['CoreNLP', 'corenlp/', 'This is my Example']);
Nils Diewald19ccee92014-12-08 11:30:08 +0000367 menuItem.highlight("this");
Nils Diewald1c546922015-04-13 01:56:19 +0000368 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span><mark>This</mark> is my Example</span>");
Nils Diewald19ccee92014-12-08 11:30:08 +0000369
370 menuItem.lowlight();
Nils Diewald1c546922015-04-13 01:56:19 +0000371 expect(menuItem.element().innerHTML).toEqual("<span>CoreNLP</span><span>This is my Example</span>");
372*/
Nils Diewald19ccee92014-12-08 11:30:08 +0000373 });
374});
375
376
Nils Diewald5c5a7472015-04-02 22:13:38 +0000377describe('KorAP.HintMenu', function () {
Nils Diewald19ccee92014-12-08 11:30:08 +0000378
379 var list = [
380 ["Constituency", "c=", "Example 1"],
381 ["Lemma", "l="],
382 ["Morphology", "m=", "Example 2"],
383 ["Part-of-Speech", "p="],
384 ["Syntax", "syn="]
385 ];
386
387
388 it('should be initializable', function () {
389
Nils Diewald58141332015-04-07 16:18:45 +0000390 var menu = KorAP.HintMenu.create(null, "cnx/", list);
Nils Diewald5c5a7472015-04-02 22:13:38 +0000391 expect(menu.context()).toEqual('cnx/');
392 expect(menu.element().nodeName).toEqual('UL');
393 expect(menu.element().style.opacity).toEqual("0");
Nils Diewald19ccee92014-12-08 11:30:08 +0000394
Nils Diewald5c5a7472015-04-02 22:13:38 +0000395 menu.limit(8);
Nils Diewald19ccee92014-12-08 11:30:08 +0000396
397 // view
398 menu.show();
399
400 // First element in list
401 expect(menu.item(0).active()).toBe(true);
402 expect(menu.item(0).noMore()).toBe(true);
403
404 // Middle element in list
405 expect(menu.item(2).active()).toBe(false);
406 expect(menu.item(2).noMore()).toBe(false);
407
408 // Last element in list
Nils Diewald5c5a7472015-04-02 22:13:38 +0000409 expect(menu.item(menu.length() - 1).active()).toBe(false);
410 expect(menu.item(menu.length() - 1).noMore()).toBe(true);
Nils Diewald19ccee92014-12-08 11:30:08 +0000411 });
412});