blob: 5967401add3875874a8b9eabc372128383e0f92f [file] [log] [blame]
Akronb46d8e32017-06-29 14:26:14 +02001function matchInfoFactory () {
2 var info = document.createElement('div');
3 info.className = 'matchinfo';
4 info.innerHTML =
5 " <div class=\"matchtable\">" +
6 " <table>" +
7 " <thead>" +
8 " <tr>" +
9 " <th>Foundry</th>" +
10 " <th>Layer</th>" +
11 " <th>Der</th>" +
12 " <th>älteste</th>" +
13 " <th>lebende</th>" +
14 " <th>Baum</th>" +
Akrone9be11d2017-06-29 20:10:58 +020015 " <th>hier</th>" +
Akronb46d8e32017-06-29 14:26:14 +020016 " </tr>" +
17 " </thead>" +
18 " <tbody>" +
19 " <tr tabindex=\"0\">" +
20 " <th>corenlp</th>" +
21 " <th>p</th>" +
22 " <td>ART</td>" +
23 " <td>ADJA</td>" +
24 " <td>ADJA<br>ADJD</td>" +
25 " <td>NN</td>" +
Akrone9be11d2017-06-29 20:10:58 +020026 " <td>ADV</td>" +
Akronb46d8e32017-06-29 14:26:14 +020027 " </tr>" +
28 " <tr tabindex=\"0\">" +
29 " <th>opennlp</th>" +
30 " <th>p</th>" +
31 " <td>ART</td>" +
32 " <td>ADJA</td>" +
33 " <td></td>" +
34 " <td>NN</td>" +
Akrone9be11d2017-06-29 20:10:58 +020035 " <td>ADV</td>" +
Akronb46d8e32017-06-29 14:26:14 +020036 " </tr>" +
37 " </tbody>" +
38 " </table>" +
39 " </div>" +
40 "</div>";
41
42 return info;
43};
44
Akron7cf33fd2017-07-03 17:33:39 +020045function matchInfoComplexFactory () {
46 var info = document.createElement('div');
47 info.className = 'matchinfo';
48 info.innerHTML =
49 " <div class=\"matchtable\">" +
50 " <table>" +
51 " <thead>" +
52 " <tr>" +
53 " <th>Foundry</th>" +
54 " <th>Layer</th>" +
55 " <th>Der</th>" +
56 " <th>älteste</th>" +
57 " <th>lebende</th>" +
58 " <th>Baum</th>" +
59 " </tr>" +
60 " </thead>" +
61 " <tbody>" +
62 " <tr tabindex=\"0\">" +
63 " <th>corenlp</th>" +
64 " <th>p</th>" +
65 " <td>ART</td>" +
66 " <td>ADJA</td>" +
67 " <td>ADJA<br>ADJD</td>" +
68 " <td class=\"matchkeyvalues\">" +
69 " <div>case:nom</div>" +
70 " <div>gender:masc<br/>gender:fem</div>" +
71 " <div>number:sg</div>" +
72 " </td>" +
73 " </tr>" +
74 " <tr tabindex=\"0\">" +
75 " <th>opennlp</th>" +
76 " <th>p</th>" +
77 " <td class=\"matchkeyvalues\">" +
78 " <div>case:nom</div>" +
79 " <div>gender:masc</div>" +
80 " <div>number:sg</div>" +
81 " </td>" +
82 " <td>ADJA</td>" +
83 " <td></td>" +
84 " <td>NN</td>" +
85 " </tr>" +
86 " </tbody>" +
87 " </table>" +
88 " </div>";
89 return info;
90};
91
Akronb46d8e32017-06-29 14:26:14 +020092
93define(['match/querycreator'], function (qcClass) {
94
95 describe('KorAP.QueryCreator', function () {
96
97 it('should be initializable', function () {
98 expect(
99 function() {
100 qcClass.create()
101 }
102 ).toThrow(new Error("Missing parameters"));
103
104 expect(
105 function() {
106 qcClass.create("Test")
107 }
108 ).toThrow(new Error("Requires element"));
109
110 expect(
111 function() {
112 var minfo = document.createElement('div');
113 qcClass.create(minfo);
114 }
115 ).toThrow(new Error("Element contains no match table"));
116
117 expect(qcClass.create(matchInfoFactory()).toString()).toEqual("");
118 });
119
120 it('should listen to click events', function () {
121
122 var matchInfo = matchInfoFactory();
123 var qc = qcClass.create(matchInfo);
124
125 // Nothing to show
126 expect(qc.toString()).toEqual("");
127 expect(qc.shown()).toBe(false);
128 qc.show();
129 expect(qc.shown()).toBe(false);
130 expect(qc.element().className).toEqual("queryfragment");
131
132 // Click on cell 0:0 "Foundry"
133 var cell = matchInfo.querySelector("thead > tr > th:first-child");
134 expect(cell.innerText).toEqual("Foundry");
135 cell.click();
136 expect(cell.classList.contains("chosen")).toBe(false);
137 expect(qc.toString()).toEqual("");
138 expect(qc.shown()).toBe(false);
139
140 // Click on cell 0:2 "Der"
141 cell = matchInfo.querySelector("thead > tr > th:nth-child(3)")
142 expect(cell.innerText).toEqual("Der");
143 cell.click();
144 expect(cell.classList.contains("chosen")).toBeTruthy();
145 expect(qc.toString()).toEqual("[orth=Der]");
146 expect(qc.shown()).toBeTruthy();
147
148 // Click on cell 0:2 "Der" again - to hide
149 cell = matchInfo.querySelector("thead > tr > th:nth-child(3)")
150 expect(cell.innerText).toEqual("Der");
151 cell.click();
152 expect(cell.classList.contains("chosen")).toBe(false);
153 expect(qc.toString()).toEqual("");
154 expect(qc.shown()).toBe(false);
155 });
156
157 it('should create tokens in arbitrary order', function () {
158 var matchInfo = matchInfoFactory();
159 var qc = qcClass.create(matchInfo);
160
161 var cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
162 expect(cell.innerText).toEqual("ADJA");
163 cell.click();
164 expect(qc.toString()).toEqual("[opennlp/p=ADJA]");
165
166 cell = matchInfo.querySelector("thead > tr > th:nth-child(4)");
167 expect(cell.innerText).toEqual("älteste");
168 cell.click();
169 expect(qc.toString()).toEqual("[opennlp/p=ADJA & orth=älteste]");
170
171 cell = matchInfo.querySelector("tbody > tr > td:nth-child(4)");
172 expect(cell.innerText).toEqual("ADJA");
173 cell.click();
174 expect(qc.toString()).toEqual("[corenlp/p=ADJA & opennlp/p=ADJA & orth=älteste]");
175 });
176
177 it('should create token sequences in arbitrary order', function () {
178 var matchInfo = matchInfoFactory();
179 var qc = qcClass.create(matchInfo);
180
181 var cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
182 expect(cell.innerText).toEqual("lebende");
183 cell.click();
184 expect(qc.toString()).toEqual("[orth=lebende]");
185
186 cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(3)");
187 expect(cell.innerText).toEqual("ART");
188 cell.click();
Akrone9be11d2017-06-29 20:10:58 +0200189 expect(qc.toString()).toEqual("[opennlp/p=ART][][orth=lebende]");
Akronb46d8e32017-06-29 14:26:14 +0200190
191 cell = matchInfo.querySelector("tbody > tr > td:nth-child(4)");
192 expect(cell.innerText).toEqual("ADJA");
193 cell.click();
194 expect(qc.toString()).toEqual("[opennlp/p=ART][corenlp/p=ADJA][orth=lebende]");
195 });
196
197 it('should remove chosen elements again', function () {
198 var matchInfo = matchInfoFactory();
199 var qc = qcClass.create(matchInfo);
200
201 var cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
202 expect(cell.innerText).toEqual("ADJA");
203 cell.click();
204 expect(qc.toString()).toEqual("[opennlp/p=ADJA]");
205 var cell1 = cell;
206
207 cell = matchInfo.querySelector("thead > tr > th:nth-child(4)");
208 expect(cell.innerText).toEqual("älteste");
209 cell.click();
210 expect(qc.toString()).toEqual("[opennlp/p=ADJA & orth=älteste]");
211 var cell2 = cell;
212
213 cell = matchInfo.querySelector("tbody > tr > td:nth-child(3)");
214 expect(cell.innerText).toEqual("ART");
215 cell.click();
216 expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste]");
217 var cell3 = cell;
218
219 cell = matchInfo.querySelector("thead > tr > th:nth-child(6)");
220 expect(cell.innerText).toEqual("Baum");
221 cell.click();
Akrone9be11d2017-06-29 20:10:58 +0200222 expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste][][orth=Baum]");
Akronb46d8e32017-06-29 14:26:14 +0200223 var cell4 = cell;
224
225 cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
226 expect(cell.innerText).toEqual("lebende");
227 cell.click();
228 expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste][orth=lebende][orth=Baum]");
229 var cell5 = cell;
230
231
232 // Remove annotations again
233 expect(cell5.classList.contains("chosen")).toBeTruthy();
234 cell5.click()
235 expect(cell5.classList.contains("chosen")).toBe(false);
Akrone9be11d2017-06-29 20:10:58 +0200236 expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste][][orth=Baum]");
Akronb46d8e32017-06-29 14:26:14 +0200237
238 expect(cell2.classList.contains("chosen")).toBeTruthy();
239 cell2.click()
240 expect(cell2.classList.contains("chosen")).toBe(false);
Akrone9be11d2017-06-29 20:10:58 +0200241 expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA][][orth=Baum]");
Akronb46d8e32017-06-29 14:26:14 +0200242
243 expect(cell1.classList.contains("chosen")).toBeTruthy();
244 cell1.click()
245 expect(cell1.classList.contains("chosen")).toBe(false);
Akrone9be11d2017-06-29 20:10:58 +0200246 expect(qc.toString()).toEqual("[corenlp/p=ART][]{2}[orth=Baum]");
Akronb46d8e32017-06-29 14:26:14 +0200247
248 // Re-add first cell at the same position
249 expect(cell1.classList.contains("chosen")).toBe(false);
250 cell1.click()
251 expect(cell1.classList.contains("chosen")).toBeTruthy();
Akrone9be11d2017-06-29 20:10:58 +0200252 expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA][][orth=Baum]");
Akronb46d8e32017-06-29 14:26:14 +0200253
254 expect(cell3.classList.contains("chosen")).toBeTruthy();
255 cell3.click()
256 expect(cell3.classList.contains("chosen")).toBe(false);
Akrone9be11d2017-06-29 20:10:58 +0200257 expect(qc.toString()).toEqual("[opennlp/p=ADJA][][orth=Baum]");
Akronb46d8e32017-06-29 14:26:14 +0200258
259 expect(cell4.classList.contains("chosen")).toBeTruthy();
260 cell4.click()
261 expect(cell4.classList.contains("chosen")).toBe(false);
262 expect(qc.toString()).toEqual("[opennlp/p=ADJA]");
263
264 // Remove last token
265 expect(qc.shown()).toBeTruthy();
266 expect(qc.element().innerHTML).toEqual("<span>New Query:</span><span>[opennlp/p=ADJA]</span>");
267 expect(cell1.classList.contains("chosen")).toBeTruthy();
268 cell1.click()
269 expect(cell1.classList.contains("chosen")).toBe(false);
270 expect(qc.toString()).toEqual("");
271 expect(qc.shown()).toBe(false);
272
273 // Re-add token
274 expect(cell4.classList.contains("chosen")).toBe(false);
275 cell4.click()
276 expect(cell4.classList.contains("chosen")).toBeTruthy();
277 expect(qc.toString()).toEqual("[orth=Baum]");
278 expect(qc.shown()).toBeTruthy();
279 expect(qc.element().innerHTML).toEqual("<span>New Query:</span><span>[orth=Baum]</span>");
280 });
281
Akronc8461bf2017-06-29 15:05:24 +0200282 it('should ignore empty terms', function () {
283 var matchInfo = matchInfoFactory();
284 var qc = qcClass.create(matchInfo);
Akronb46d8e32017-06-29 14:26:14 +0200285
Akronc8461bf2017-06-29 15:05:24 +0200286 // Nothing to show
287 expect(qc.toString()).toEqual("");
288 expect(qc.shown()).toBe(false);
289 qc.show();
290 expect(qc.shown()).toBe(false);
291 expect(qc.element().className).toEqual("queryfragment");
292
293 var cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)");
294 expect(cell.innerText).toEqual("ADJA");
295 expect(cell.classList.contains("chosen")).toBe(false);
296 cell.click();
297 expect(cell.classList.contains("chosen")).toBeTruthy();
298 expect(qc.toString()).toEqual("[opennlp/p=ADJA]");
299
300 cell = matchInfo.querySelector("tbody > tr:nth-child(2) > td:nth-child(5)");
301 expect(cell.innerText).toEqual("");
302 expect(cell.classList.contains("chosen")).toBe(false);
303 cell.click();
304 expect(cell.classList.contains("chosen")).toBe(false);
305 expect(qc.toString()).toEqual("[opennlp/p=ADJA]");
306
307 });
308
Akron7cf33fd2017-07-03 17:33:39 +0200309 it('should create or-groups for alternative terms', function () {
Akronc8461bf2017-06-29 15:05:24 +0200310 var matchInfo = matchInfoFactory();
311 var qc = qcClass.create(matchInfo);
312
313 // Nothing to show
314 expect(qc.toString()).toEqual("");
315 expect(qc.shown()).toBe(false);
316 qc.show();
317 expect(qc.shown()).toBe(false);
318 expect(qc.element().className).toEqual("queryfragment");
319
320 var cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
321 expect(cell.innerText).toEqual("lebende");
322 expect(cell.classList.contains("chosen")).toBe(false);
323 cell.click();
324 expect(cell.classList.contains("chosen")).toBeTruthy();
325 expect(qc.toString()).toEqual("[orth=lebende]");
326
327 cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(5)");
328 expect(cell.innerText).toEqual("ADJAADJD");
329 expect(cell.classList.contains("chosen")).toBe(false);
330 cell.click();
331 expect(cell.classList.contains("chosen")).toBeTruthy();
332 expect(qc.toString()).toEqual("[(corenlp/p=ADJA | corenlp/p=ADJD) & orth=lebende]");
333
334 // Remove or group again
335 expect(cell.classList.contains("chosen")).toBeTruthy();
336 cell.click();
337 expect(cell.classList.contains("chosen")).toBe(false);
338 expect(qc.toString()).toEqual("[orth=lebende]");
339 });
340
341
342 it('should add whole rows', function () {
343 var matchInfo = matchInfoFactory();
344 var qc = qcClass.create(matchInfo);
345
346 // Nothing to show
347 expect(qc.toString()).toEqual("");
348 expect(qc.shown()).toBe(false);
349 qc.show();
350 expect(qc.shown()).toBe(false);
351 expect(qc.element().className).toEqual("queryfragment");
352
353 var corenlpRow = matchInfo.querySelector("tbody > tr:nth-child(1)");
354
355 var cell = corenlpRow.querySelector("td:nth-child(4)");
356 expect(cell.innerText).toEqual("ADJA");
357 expect(cell.classList.contains("chosen")).toBe(false);
358 cell.click();
359 expect(cell.classList.contains("chosen")).toBeTruthy();
360
361 // Activate another cell in another row
362 cell = matchInfo.querySelector("tbody > tr:nth-child(2) td:nth-child(3)");
363 expect(cell.innerText).toEqual("ART");
364 expect(cell.classList.contains("chosen")).toBe(false);
365 cell.click();
366 expect(cell.classList.contains("chosen")).toBeTruthy();
367
368 expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeNull();
369 expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy();
370 expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeNull();
371 expect(corenlpRow.querySelector("td:nth-child(6).chosen")).toBeNull();
372
373 expect(qc.toString()).toEqual("[opennlp/p=ART][corenlp/p=ADJA]");
374
375 // Mark all corenlp lists
376 cell = corenlpRow.querySelector("th:nth-child(1)");
377 expect(cell.innerText).toEqual("corenlp");
378 expect(cell.classList.contains("chosen")).toBe(false);
379 cell.click();
380 expect(cell.classList.contains("chosen")).toBe(false);
381
382 expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeTruthy();
383 expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy();
384 expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeTruthy();
385 expect(corenlpRow.querySelector("td:nth-child(6).chosen")).toBeTruthy();
386
387 // Replay the choice without any effect
388 cell = corenlpRow.querySelector("th:nth-child(1)");
389 expect(cell.innerText).toEqual("corenlp");
390 expect(cell.classList.contains("chosen")).toBe(false);
391 cell.click();
392 expect(cell.classList.contains("chosen")).toBe(false);
393
394 expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeTruthy();
395 expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy();
396 expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeTruthy();
397 expect(corenlpRow.querySelector("td:nth-child(6).chosen")).toBeTruthy();
Akrone9be11d2017-06-29 20:10:58 +0200398 expect(corenlpRow.querySelector("td:nth-child(7).chosen")).toBeTruthy();
Akronc8461bf2017-06-29 15:05:24 +0200399
Akrone9be11d2017-06-29 20:10:58 +0200400 expect(qc.toString()).toEqual("[corenlp/p=ART & opennlp/p=ART][corenlp/p=ADJA][(corenlp/p=ADJA | corenlp/p=ADJD)][corenlp/p=NN][corenlp/p=ADV]");
Akronc8461bf2017-06-29 15:05:24 +0200401
402 // Remove one of the cells again
403 cell = corenlpRow.querySelector("td:nth-child(5).chosen");
404 expect(cell.innerText).toEqual("ADJAADJD");
405 expect(cell.classList.contains("chosen")).toBeTruthy();
406 cell.click();
407 expect(cell.classList.contains("chosen")).toBe(false);
Akrone9be11d2017-06-29 20:10:58 +0200408 expect(qc.toString()).toEqual("[corenlp/p=ART & opennlp/p=ART][corenlp/p=ADJA][][corenlp/p=NN][corenlp/p=ADV]");
Akronc8461bf2017-06-29 15:05:24 +0200409
410 });
Akron8084cb52017-06-29 17:11:14 +0200411
412 it('should ignore empty terms in whole rows', function () {
413 var matchInfo = matchInfoFactory();
414 var qc = qcClass.create(matchInfo);
415 expect(qc.toString()).toEqual("");
416
417 var opennlpRow = matchInfo.querySelector("tbody > tr:nth-child(2)");
418
419 expect(opennlpRow.querySelector("td:nth-child(3).chosen")).toBeNull();
420 expect(opennlpRow.querySelector("td:nth-child(4).chosen")).toBeNull();
421 expect(opennlpRow.querySelector("td:nth-child(5).chosen")).toBeNull();
422 expect(opennlpRow.querySelector("td:nth-child(6).chosen")).toBeNull();
423
424 expect(qc.toString()).toEqual("");
425
426 // Mark all opennlp lists
427 cell = opennlpRow.querySelector("th:nth-child(1)");
428 expect(cell.innerText).toEqual("opennlp");
429 expect(cell.classList.contains("chosen")).toBe(false);
430 cell.click();
431 expect(cell.classList.contains("chosen")).toBe(false);
432
433 expect(opennlpRow.querySelector("td:nth-child(3).chosen")).toBeTruthy();
434 expect(opennlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy();
435 expect(opennlpRow.querySelector("td:nth-child(5).chosen")).toBeNull();
436 expect(opennlpRow.querySelector("td:nth-child(6).chosen")).toBeTruthy();
Akron7cf33fd2017-07-03 17:33:39 +0200437
438 expect(qc.toString()).toEqual("[opennlp/p=ART][opennlp/p=ADJA][][opennlp/p=NN][opennlp/p=ADV]");
Akron8084cb52017-06-29 17:11:14 +0200439 });
Akrone9be11d2017-06-29 20:10:58 +0200440
441 it('should support multiple distances', function () {
442 var matchInfo = matchInfoFactory();
443 var qc = qcClass.create(matchInfo);
444
445 var cell = matchInfo.querySelector("thead > tr > th:nth-child(3)");
446 expect(cell.innerText).toEqual("Der");
447 cell.click();
448 expect(qc.toString()).toEqual("[orth=Der]");
449
450 cell = matchInfo.querySelector("thead > tr > th:nth-child(7)");
451 expect(cell.innerText).toEqual("hier");
452 cell.click();
453 expect(qc.toString()).toEqual("[orth=Der][]{3}[orth=hier]");
454
455 cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
456 expect(cell.innerText).toEqual("lebende");
457 cell.click();
458 expect(qc.toString()).toEqual("[orth=Der][][orth=lebende][][orth=hier]");
459 });
Akron7cf33fd2017-07-03 17:33:39 +0200460
461 it('should create and-groups for key-value terms', function () {
462 var matchInfo = matchInfoComplexFactory();
463 var qc = qcClass.create(matchInfo);
464
465 // Nothing to show
466 expect(qc.toString()).toEqual("");
467 expect(qc.shown()).toBe(false);
468 qc.show();
469 expect(qc.shown()).toBe(false);
470 expect(qc.element().className).toEqual("queryfragment");
471
472 var cell = matchInfo.querySelector("thead > tr > th:nth-child(5)");
473 expect(cell.innerText).toEqual("lebende");
474 expect(cell.classList.contains("chosen")).toBe(false);
475 cell.click();
476 expect(cell.classList.contains("chosen")).toBeTruthy();
477 expect(qc.toString()).toEqual("[orth=lebende]");
478
479 // Check complex cell
480 cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(6)");
481 expect(cell.innerText).toMatch(/case:nom/);
482 expect(cell.classList.contains("chosen")).toBe(false);
483 cell.click();
484 expect(cell.classList.contains("chosen")).toBe(false);
485 expect(qc.toString()).toEqual("[orth=lebende]");
486
487 // Check complex cell div
488 cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(1)");
489 expect(cell.innerText).toEqual('case:nom');
490 expect(cell.classList.contains("chosen")).toBe(false);
491 cell.click();
492 expect(cell.classList.contains("chosen")).toBe(true);
493 expect(qc.toString()).toEqual("[orth=lebende][corenlp/p=case:nom]");
494 var cell = cell;
495
496 cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(3)");
497 expect(cell.innerText).toEqual('number:sg');
498 expect(cell.classList.contains("chosen")).toBe(false);
499 cell.click();
500 expect(cell.classList.contains("chosen")).toBe(true);
501 expect(qc.toString()).toEqual("[orth=lebende][corenlp/p=case:nom & corenlp/p=number:sg]");
502 var cell2 = cell;
503
504 cell = matchInfo.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(2)");
505 expect(cell.innerText).toEqual('gender:mascgender:fem');
506 expect(cell.classList.contains("chosen")).toBe(false);
507 cell.click();
508 expect(cell.classList.contains("chosen")).toBe(true);
509 expect(qc.toString()).toEqual("[orth=lebende][(corenlp/p=gender:fem | corenlp/p=gender:masc) & corenlp/p=case:nom & corenlp/p=number:sg]");
510 var cell3 = cell;
511
512 // Remove cell again
513 cell = cell2;
514 expect(cell.innerText).toEqual('number:sg');
515 expect(cell.classList.contains("chosen")).toBe(true);
516 cell.click();
517 expect(cell.classList.contains("chosen")).toBe(false);
518 expect(qc.toString()).toEqual("[orth=lebende][(corenlp/p=gender:fem | corenlp/p=gender:masc) & corenlp/p=case:nom]");
519
520 // Remove cell again
521 cell = cell3;
522 expect(cell.innerText).toEqual('gender:mascgender:fem');
523 expect(cell.classList.contains("chosen")).toBe(true);
524 cell.click();
525 expect(cell.classList.contains("chosen")).toBe(false);
526 expect(qc.toString()).toEqual("[orth=lebende][corenlp/p=case:nom]");
527 });
528
529
530 it('should create rows including key-value terms', function () {
531 var matchInfo = matchInfoComplexFactory();
532 var qc = qcClass.create(matchInfo);
533 expect(qc.toString()).toEqual("");
534
535 var corenlpRow = matchInfo.querySelector("tbody > tr:nth-child(1)");
536
537 expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeNull();
538 expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeNull();
539 expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeNull();
540 expect(corenlpRow.querySelector("td:nth-child(6) *.chosen")).toBeNull();
541
542 expect(qc.toString()).toEqual("");
543
544 // Mark all opennlp lists
545 cell = corenlpRow.querySelector("th:nth-child(1)");
546 expect(cell.innerText).toEqual("corenlp");
547 expect(cell.classList.contains("chosen")).toBe(false);
548 cell.click();
549 expect(cell.classList.contains("chosen")).toBe(false);
550
551 expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeTruthy();
552 expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy();
553 expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeTruthy();
554 expect(corenlpRow.querySelector("td:nth-child(6) div:nth-child(1).chosen")).toBeTruthy();
555 expect(corenlpRow.querySelector("td:nth-child(6) div:nth-child(2).chosen")).toBeTruthy();
556 expect(corenlpRow.querySelector("td:nth-child(6) div:nth-child(3).chosen")).toBeTruthy();
557
558 expect(qc.toString()).toEqual(
559 "[corenlp/p=ART]"+
560 "[corenlp/p=ADJA]"+
561 "[(corenlp/p=ADJA | corenlp/p=ADJD)]"+
562 "[(corenlp/p=gender:fem | corenlp/p=gender:masc) & corenlp/p=case:nom & corenlp/p=number:sg]"
563 );
564 });
Akronb46d8e32017-06-29 14:26:14 +0200565 });
566});