blob: 1f2eb3417513283eb51654cd587a29eb5f494170 [file] [log] [blame]
Nils Diewald7c8ced22015-04-15 19:21:00 +00001// Regarding async:
2// http://stackoverflow.com/questions/16423156/getting-requirejs-to-work-with-jasmine
3
Nils Diewalda297f062015-04-02 00:23:46 +00004var available = [
5 'base/s=spans',
6 'corenlp/c=spans',
7 'corenlp/ne=tokens',
8 'corenlp/p=tokens',
9 'corenlp/s=spans',
10 'glemm/l=tokens',
11 'mate/l=tokens',
12 'mate/m=tokens',
13 'mate/p=tokens',
14 'opennlp/p=tokens',
15 'opennlp/s=spans',
16 'tt/l=tokens',
17 'tt/p=tokens',
18 'tt/s=spans'
19];
20
21var match = {
22 'corpusID' : 'WPD',
23 'docID' : 'UUU',
24 'textID' : '01912',
25 'matchID' : 'p121-122',
Akron0a6768f2016-07-13 18:00:43 +020026 'textSigle' : 'WPD/UUU/01912',
Nils Diewalda297f062015-04-02 00:23:46 +000027 'available' : available
28};
29
30var snippet = "<span title=\"cnx/l:meist\">" +
31 " <span title=\"cnx/p:ADV\">" +
32 " <span title=\"cnx/syn:@PREMOD\">" +
33 " <span title=\"mate/l:meist\">" +
34 " <span title=\"mate/p:ADV\">" +
35 " <span title=\"opennlp/p:ADV\">meist</span>" +
36 " </span>" +
37 " </span>" +
38 " </span>" +
39 " </span>" +
40 "</span>" +
41 "<span title=\"cnx/l:deutlich\">" +
42 " <span title=\"cnx/p:A\">" +
43 " <span title=\"cnx/syn:@PREMOD\">" +
44 " <span title=\"mate/l:deutlich\">" +
45 " <span title=\"mate/m:degree:pos\">" +
46 " <span title=\"mate/p:ADJD\">" +
47 " <span title=\"opennlp/p:ADJD\">deutlich</span>" +
48 " </span>" +
49 " </span>" +
50 " </span>" +
51 " </span>" +
52 " </span>" +
53 "</span>" +
54 "<span title=\"cnx/l:fähig\">" +
55 " <span title=\"cnx/l:leistung\">" +
56 " <span title=\"cnx/p:A\">" +
57 " <span title=\"cnx/syn:@NH\">" +
58 " <span title=\"mate/l:leistungsfähig\">" +
59 " <span title=\"mate/m:degree:comp\">" +
60 " <span title=\"mate/p:ADJD\">" +
61 " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" +
62 " </span>" +
63 " </span>" +
64 " </span>" +
65 " </span>" +
66 " </span>" +
67 " </span>" +
68 "</span>";
69
70var treeSnippet =
71 "<span class=\"context-left\"></span>" +
72 "<span class=\"match\">" +
73 " <span title=\"xip/c:MC\">" +
74 " <span title=\"xip/c:TOP\">" +
75 " <span title=\"xip/c:PP\">" +
76 " <span title=\"xip/c:PREP\">Mit</span>" +
77 " <span title=\"xip/c:NP\">" +
78 " <span title=\"xip/c:DET\">dieser</span>" +
79 " <span title=\"xip/c:NPA\">" +
80 " <span title=\"xip/c:NOUN\">Methode</span>" +
81 " </span>" +
82 " </span>" +
83 " </span>" +
84 " <span title=\"xip/c:VERB\">ist</span>" +
Akron98a933f2016-08-11 00:19:17 +020085 " <mark>" +
86 " <span title=\"xip/c:NP\">" +
87 " <span title=\"xip/c:PRON\">es</span>" +
88 " </span>" +
89 " <span title=\"xip/c:AP\">" +
90 " <span title=\"xip/c:ADV\">nun</span>" +
91 " <span title=\"xip/c:ADJ\">möglich</span>" +
92 " </span>" +
93 " </mark>" +
Nils Diewalda297f062015-04-02 00:23:46 +000094 " <span title=\"xip/c:ADV\">z. B.</span>" +
95 " <span title=\"xip/c:NPA\">" +
96 " <span title=\"xip/c:NP\">" +
97 " <span title=\"xip/c:NOUN\">Voice</span>" +
98 " </span>" +
99 " </span>" + "(" +
100 " <span title=\"xip/c:INS\">" +
101 " <span title=\"xip/c:NPA\">" +
102 " <span title=\"xip/c:NP\">" +
103 " <span title=\"xip/c:NOUN\">Sprache</span>" +
104 " </span>" +
105 " </span>" +
106 " </span>" + ")" +
107 " <span title=\"xip/c:VERB\">bevorzugt</span>" +
108 " <span title=\"xip/c:PP\">" +
109 " <span title=\"xip/c:PREP\">in</span>" +
110 " <span title=\"xip/c:NP\">" +
111 " <span title=\"xip/c:PRON\">der</span>" +
112 " </span>" +
113 " <span title=\"xip/c:NPA\">" +
114 " <span title=\"xip/c:NP\">" +
115 " <span title=\"xip/c:NOUN\">Bridge</span>" +
116 " </span>" +
117 " </span>" +
118 " </span>" +
119 " <span title=\"xip/c:INFC\">" +
120 " <span title=\"xip/c:INS\">" +
121 " <span title=\"xip/c:VERB\">weiterzugeben</span>" +
122 " </span>" +
123 " </span>" +
124 " </span>" +
125 " </span>" +
126 "</span>" +
127 "<span class=\"context-right\"></span>";
128
129
130function matchElementFactory () {
131 var me = document.createElement('li');
132
133 me.setAttribute(
134 'data-available-info',
135 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' +
136 ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' +
137 ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' +
138 ' tt/p=tokens tt/s=spans');
139
140 me.setAttribute('data-corpus-id', 'WPD');
141 me.setAttribute('data-doc-id', 'FFF');
142 me.setAttribute('data-text-id', '01460');
Akron0a6768f2016-07-13 18:00:43 +0200143 me.setAttribute('data-text-sigle', 'WPD/FFF/01460');
Nils Diewalda297f062015-04-02 00:23:46 +0000144 me.setAttribute('data-match-id', 'p119-120');
145 me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>';
146 return me;
147};
148
149
Nils Diewald7c8ced22015-04-15 19:21:00 +0000150define(['match'], function () {
Nils Diewald58141332015-04-07 16:18:45 +0000151
Nils Diewald7c8ced22015-04-15 19:21:00 +0000152 // Override getMatchInfo API call
153 KorAP.API.getMatchInfo = function (x, param, cb) {
154 if (param['spans'] === undefined || param['spans'] === false)
155 cb({ "snippet": snippet });
156 else
157 cb({ "snippet": treeSnippet });
Nils Diewalda297f062015-04-02 00:23:46 +0000158 };
159
Nils Diewald7c8ced22015-04-15 19:21:00 +0000160 describe('KorAP.InfoLayer', function () {
161
162 var infoClass = require('match/infolayer');
Nils Diewalda297f062015-04-02 00:23:46 +0000163
Nils Diewald7c8ced22015-04-15 19:21:00 +0000164 it('should be initializable', function () {
165 expect(
166 function() { infoClass.create() }
167 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000168
Nils Diewald7c8ced22015-04-15 19:21:00 +0000169 expect(
170 function() { infoClass.create("base") }
171 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000172
Nils Diewald7c8ced22015-04-15 19:21:00 +0000173 var layer = infoClass.create("base", "s");
174 expect(layer).toBeTruthy();
175 expect(layer.foundry).toEqual("base");
176 expect(layer.layer).toEqual("s");
177 expect(layer.type).toEqual("tokens");
Nils Diewalda297f062015-04-02 00:23:46 +0000178
Nils Diewald7c8ced22015-04-15 19:21:00 +0000179 layer = infoClass.create("cnx", "syn", "spans");
180 expect(layer).toBeTruthy();
181 expect(layer.foundry).toEqual("cnx");
182 expect(layer.layer).toEqual("syn");
183 expect(layer.type).toEqual("spans");
Nils Diewald58141332015-04-07 16:18:45 +0000184 });
185 });
Nils Diewalda297f062015-04-02 00:23:46 +0000186
Nils Diewalda297f062015-04-02 00:23:46 +0000187
Nils Diewald7c8ced22015-04-15 19:21:00 +0000188 describe('KorAP.Match', function () {
189 var match = {
190 'corpusID' : 'WPD',
191 'docID' : 'UUU',
192 'textID' : '01912',
193 'matchID' : 'p121-122',
Akron0a6768f2016-07-13 18:00:43 +0200194 'textSigle' : 'WPD/UUU/01912',
Nils Diewald7c8ced22015-04-15 19:21:00 +0000195 'available' : available
196 };
197
198 var matchClass = require('match');
199
200 it('should be initializable by Object', function () {
201 expect(function() {
202 matchClass.create()
203 }).toThrow(new Error('Missing parameters'));
204
205 expect(matchClass.create(match)).toBeTruthy();
206
207 var m = matchClass.create(match);
Akron0a6768f2016-07-13 18:00:43 +0200208 expect(m.textSigle).toEqual("WPD/UUU/01912");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000209 expect(m.matchID).toEqual("p121-122");
210
211 // /corpus/WPD/UUU.01912/p121-122/matchInfo?spans=false&foundry=*
212 var m = matchClass.create(match);
213
214 // Spans:
215 var spans = m.getSpans();
216 expect(spans[0].foundry).toEqual("base");
217 expect(spans[0].layer).toEqual("s");
218
219 expect(spans[1].foundry).toEqual("corenlp");
220 expect(spans[1].layer).toEqual("c");
221
222 expect(spans[2].foundry).toEqual("corenlp");
223 expect(spans[2].layer).toEqual("s");
224
225 expect(spans[spans.length-1].foundry).toEqual("tt");
226 expect(spans[spans.length-1].layer).toEqual("s");
227
228 // Tokens:
229 var tokens = m.getTokens();
230 expect(tokens[0].foundry).toEqual("corenlp");
231 expect(tokens[0].layer).toEqual("ne");
232
233 expect(tokens[1].foundry).toEqual("corenlp");
234 expect(tokens[1].layer).toEqual("p");
235
236 expect(tokens[tokens.length-1].foundry).toEqual("tt");
237 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewald58141332015-04-07 16:18:45 +0000238 });
Nils Diewalda297f062015-04-02 00:23:46 +0000239
240
Nils Diewald7c8ced22015-04-15 19:21:00 +0000241 it('should be initializable by Node', function () {
242 var m = matchClass.create(matchElementFactory());
Akron0a6768f2016-07-13 18:00:43 +0200243 expect(m.textSigle).toEqual("WPD/FFF/01460");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000244 expect(m.matchID).toEqual("p119-120");
Nils Diewalda297f062015-04-02 00:23:46 +0000245
Nils Diewald7c8ced22015-04-15 19:21:00 +0000246 // Spans:
247 var spans = m.getSpans();
248 expect(spans[0].foundry).toEqual("base");
249 expect(spans[0].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000250
Nils Diewald7c8ced22015-04-15 19:21:00 +0000251 expect(spans[1].foundry).toEqual("corenlp");
252 expect(spans[1].layer).toEqual("c");
Nils Diewalda297f062015-04-02 00:23:46 +0000253
Nils Diewald7c8ced22015-04-15 19:21:00 +0000254 expect(spans[2].foundry).toEqual("corenlp");
255 expect(spans[2].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000256
Nils Diewald7c8ced22015-04-15 19:21:00 +0000257 expect(spans[spans.length-1].foundry).toEqual("tt");
258 expect(spans[spans.length-1].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000259
Nils Diewald7c8ced22015-04-15 19:21:00 +0000260 // Tokens:
261 var tokens = m.getTokens();
262 expect(tokens[0].foundry).toEqual("corenlp");
263 expect(tokens[0].layer).toEqual("ne");
Nils Diewalda297f062015-04-02 00:23:46 +0000264
Nils Diewald7c8ced22015-04-15 19:21:00 +0000265 expect(tokens[1].foundry).toEqual("corenlp");
266 expect(tokens[1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000267
Nils Diewald7c8ced22015-04-15 19:21:00 +0000268 expect(tokens[tokens.length-1].foundry).toEqual("tt");
269 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000270
Nils Diewald7c8ced22015-04-15 19:21:00 +0000271 });
Nils Diewalda297f062015-04-02 00:23:46 +0000272
Nils Diewald7c8ced22015-04-15 19:21:00 +0000273 it('should react to gui actions', function () {
274 var e = matchElementFactory();
Nils Diewalda297f062015-04-02 00:23:46 +0000275
Nils Diewald7c8ced22015-04-15 19:21:00 +0000276 expect(e.classList.contains('active')).toBe(false);
277 expect(e["_match"]).toBe(undefined);
Nils Diewalda297f062015-04-02 00:23:46 +0000278
Nils Diewald7c8ced22015-04-15 19:21:00 +0000279 var m = matchClass.create(e);
280
281 expect(e.classList.contains('active')).toBe(false);
282 expect(e["_match"]).not.toBe(undefined);
283
284 // Open the match
285 m.open();
286
287 expect(e.classList.contains('active')).toBe(true);
288 expect(e["_match"]).not.toBe(undefined);
289
290 // Close the match
291 m.close();
292 expect(e.classList.contains('active')).toBe(false);
293 expect(e["_match"]).not.toBe(undefined);
294
Nils Diewald58141332015-04-07 16:18:45 +0000295 });
296 });
Nils Diewalda297f062015-04-02 00:23:46 +0000297
Nils Diewald7c8ced22015-04-15 19:21:00 +0000298
299 describe('KorAP.MatchInfo', function () {
300
301 var matchClass = require('match');
302
303 var m = matchClass.create(match);
304 var info = m.info();
305
306 it('should contain a valid info', function () {
307 expect(m._info).toEqual(info);
308 });
309
310 var table1, table2;
311
312 // Async preparation
313 it('should fail to load a table async', function (done) {
314 expect(info).toBeTruthy();
315
316 info.getTable([], function (tablen) {
317 table1 = tablen;
318 done();
319 });
320 });
321
322 it('should\'nt be parsable (async)', function () {
323 expect(table1).not.toBeTruthy();
324 });
325
326 it('should load a working table async', function(done) {
327 expect(info).toBeTruthy();
328 info.getTable(undefined, function (tablem) {
329 table2 = tablem;
330 done();
331 });
332 });
333
334 it('should parse into a table (async)', function () {
335 expect(table2).toBeTruthy();
336
337 expect(table2.length()).toBe(3);
338
339 expect(table2.getToken(0)).toBe("meist");
340 expect(table2.getToken(1)).toBe("deutlich");
341 expect(table2.getToken(2)).toBe("leistungsfähiger");
342
343 expect(table2.getValue(0, "cnx", "p")[0]).toBe("ADV");
344 expect(table2.getValue(0, "cnx", "syn")[0]).toBe("@PREMOD");
345
346 expect(table2.getValue(2, "cnx", "l")[0]).toBe("fähig");
347 expect(table2.getValue(2, "cnx", "l")[1]).toBe("leistung");
348 });
349
350 it('should parse into a table view', function () {
351 var matchElement = matchElementFactory();
352 expect(matchElement.tagName).toEqual('LI');
353
354 // Match
355 expect(matchElement.children[0].tagName).toEqual('DIV');
356
357 // snippet
358 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
359 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
360 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
361
362 // reference
363 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
364 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
365
366 // not yet
367 expect(matchElement.children[0].children[1]).toBe(undefined);
368
369 var info = matchClass.create(matchElement).info();
370 info.toggle();
371
372 // Match
373 expect(matchElement.children[0].tagName).toEqual('DIV');
374
375 // snippet
376 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
377 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
378 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
379
380 // reference
381 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
382 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
383
384 // now
385 var infotable = matchElement.children[0].children[1];
386 expect(infotable.tagName).toEqual('DIV');
387 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
388
389 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
390 expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
391 });
392
393 var tree;
394 it('should parse into a tree (async) 1', function (done) {
395 var info = matchClass.create(match).info();
396 expect(info).toBeTruthy();
397 info.getTree(undefined, undefined, function (treem) {
Akron98a933f2016-08-11 00:19:17 +0200398 tree = treem;
399 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000400 });
401 });
402
403 it('should parse into a tree (async) 2', function () {
404 expect(tree).toBeTruthy();
405 expect(tree.nodes()).toEqual(49);
406 });
Nils Diewalda297f062015-04-02 00:23:46 +0000407
Akron98a933f2016-08-11 00:19:17 +0200408 var matchElement, info;
409 // var info, matchElement;
410 it('should parse into a tree view', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000411 matchElement = matchElementFactory();
412 expect(matchElement.tagName).toEqual('LI');
Nils Diewalda297f062015-04-02 00:23:46 +0000413
Nils Diewald7c8ced22015-04-15 19:21:00 +0000414 info = matchClass.create(matchElement).info();
415 info.toggle();
Nils Diewalda297f062015-04-02 00:23:46 +0000416
Nils Diewald7c8ced22015-04-15 19:21:00 +0000417 // Match
418 expect(matchElement.children[0].tagName).toEqual('DIV');
Nils Diewalda297f062015-04-02 00:23:46 +0000419
Nils Diewald7c8ced22015-04-15 19:21:00 +0000420 // snippet
421 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
422 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
423 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
Nils Diewalda297f062015-04-02 00:23:46 +0000424
Nils Diewald7c8ced22015-04-15 19:21:00 +0000425 // reference
426 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
427 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
Nils Diewalda297f062015-04-02 00:23:46 +0000428
Nils Diewald7c8ced22015-04-15 19:21:00 +0000429 // now
430 var infotable = matchElement.children[0].children[1];
431 expect(infotable.tagName).toEqual('DIV');
432 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
433 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
434 expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
435 });
Nils Diewalda297f062015-04-02 00:23:46 +0000436
Nils Diewald7c8ced22015-04-15 19:21:00 +0000437 it('should add a tree view async 1', function (done) {
438 expect(info).toBeTruthy();
439 info.addTree('mate', 'beebop', function () {
Akron98a933f2016-08-11 00:19:17 +0200440 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000441 });
442 });
443
444 it('should add a tree view async 2', function () {
445 // With added tree
446 var infotable = matchElement.children[0].children[1];
447 expect(infotable.tagName).toEqual('DIV');
448 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
449 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
450 expect(infotable.children[1].classList.contains('addtree')).toBe(false);
451
452 var tree = infotable.children[1];
453 expect(tree.tagName).toEqual('DIV');
454 expect(tree.classList.contains('matchtree')).toBeTruthy();
455 expect(tree.children[0].tagName).toEqual('H6');
456 expect(tree.children[0].children[0].tagName).toEqual('SPAN');
457 expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate');
458 expect(tree.children[0].children[1].tagName).toEqual('SPAN');
459 expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop');
460
461 expect(tree.children[1].tagName).toEqual('DIV');
Nils Diewald58141332015-04-07 16:18:45 +0000462 });
463 });
Nils Diewalda297f062015-04-02 00:23:46 +0000464
Nils Diewalda297f062015-04-02 00:23:46 +0000465
Nils Diewald7c8ced22015-04-15 19:21:00 +0000466 describe('KorAP.MatchTable', function () {
Nils Diewalda297f062015-04-02 00:23:46 +0000467
Nils Diewald7c8ced22015-04-15 19:21:00 +0000468 var matchClass = require('match');
Nils Diewalda297f062015-04-02 00:23:46 +0000469
Nils Diewald7c8ced22015-04-15 19:21:00 +0000470 var table;
471 it('should be retrieved async', function (done) {
472 var info = matchClass.create(match).info();
473 expect(info).toBeTruthy();
474 info.getTable(undefined, function (x) {
475 table = x;
476 done();
477 });
478 });
Nils Diewalda297f062015-04-02 00:23:46 +0000479
Nils Diewald7c8ced22015-04-15 19:21:00 +0000480 it('should be rendered async', function () {
481 var e = table.element();
482
483 expect(e.nodeName).toBe('TABLE');
484 expect(e.children[0].nodeName).toBe('THEAD');
485 var tr = e.children[0].children[0];
486 expect(tr.nodeName).toBe('TR');
487 expect(tr.children[0].nodeName).toBe('TH');
Nils Diewald58141332015-04-07 16:18:45 +0000488
Nils Diewald7c8ced22015-04-15 19:21:00 +0000489 expect(tr.children[0].firstChild.nodeValue).toBe('Foundry');
490 expect(tr.children[1].firstChild.nodeValue).toBe('Layer');
491 expect(tr.children[2].firstChild.nodeValue).toBe('meist');
492 expect(tr.children[3].firstChild.nodeValue).toBe('deutlich');
493 expect(tr.children[4].firstChild.nodeValue).toBe('leistungsfähiger');
494
495 // first row
496 tr = e.children[1].children[0];
497 expect(tr.nodeName).toBe('TR');
498 expect(tr.getAttribute('tabindex')).toEqual('0');
499 expect(tr.children[0].nodeName).toBe('TH');
500 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
501 expect(tr.children[1].firstChild.nodeValue).toEqual('l');
502 expect(tr.children[2].firstChild.nodeValue).toEqual('meist');
503 expect(tr.children[3].firstChild.nodeValue).toEqual('deutlich');
504 expect(tr.children[4].firstChild.nodeValue).toEqual('fähig');
505 expect(tr.children[4].lastChild.nodeValue).toEqual('leistung');
506
507 // second row
508 tr = e.children[1].children[1];
509 expect(tr.nodeName).toBe('TR');
510 expect(tr.getAttribute('tabindex')).toEqual('0');
511 expect(tr.children[0].nodeName).toBe('TH');
512 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
513 expect(tr.children[1].firstChild.nodeValue).toEqual('p');
514 expect(tr.children[2].firstChild.nodeValue).toEqual('ADV');
515 expect(tr.children[3].firstChild.nodeValue).toEqual('A');
516 expect(tr.children[4].firstChild.nodeValue).toEqual('A');
Nils Diewald58141332015-04-07 16:18:45 +0000517 });
518 });
Nils Diewalda297f062015-04-02 00:23:46 +0000519
Nils Diewald7c8ced22015-04-15 19:21:00 +0000520 describe('KorAP.MatchTree', function () {
521 var tree;
522 var matchClass = require('match');
Nils Diewalda297f062015-04-02 00:23:46 +0000523
Nils Diewald7c8ced22015-04-15 19:21:00 +0000524 it('should be rendered async 1', function (done) {
525 var info = matchClass.create(match).info();
526 expect(info).toBeTruthy();
527 info.getTree(undefined, undefined, function (y) {
528 tree = y;
529 done();
530 });
531 });
Nils Diewalda297f062015-04-02 00:23:46 +0000532
Nils Diewald7c8ced22015-04-15 19:21:00 +0000533 it('should be rendered async 2', function () {
534 var e = tree.element();
535 expect(e.nodeName).toEqual('svg');
536 expect(e.getElementsByTagName('g').length).toEqual(48);
Nils Diewald58141332015-04-07 16:18:45 +0000537 });
538 });
Nils Diewalda297f062015-04-02 00:23:46 +0000539
Nils Diewald7c8ced22015-04-15 19:21:00 +0000540
541 describe('KorAP.MatchTreeItem', function () {
542 var matchTreeItemClass = require('match/treeitem');
543 it('should be initializable', function () {
544 var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c'])
545 expect(mi.element().firstChild.nodeValue).toEqual('cnx/c');
546 expect(mi.lcField()).toEqual(' cnx/c');
547 expect(mi.foundry()).toEqual('cnx');
548 expect(mi.layer()).toEqual('c');
549 });
Nils Diewalda297f062015-04-02 00:23:46 +0000550 });
Nils Diewalda297f062015-04-02 00:23:46 +0000551
552
Nils Diewald7c8ced22015-04-15 19:21:00 +0000553 describe('KorAP.MatchTreeMenu', function () {
554 var matchTreeMenu = require('match/treemenu');
555 var matchTreeItem = require('match/treeitem');
556
557 it('should be initializable', function () {
558 var menu = matchTreeMenu.create(undefined, [
Akronaba7a5a2016-08-15 21:58:33 +0200559 ['cnx/c', 'cnx', 'c'],
560 ['xip/c', 'xip', 'c']
Nils Diewald7c8ced22015-04-15 19:21:00 +0000561 ]);
562
563 expect(menu.itemClass()).toEqual(matchTreeItem);
564 expect(menu.element().nodeName).toEqual('UL');
Akronaba7a5a2016-08-15 21:58:33 +0200565 expect(menu.element().classList.contains('visible')).toBeFalsy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000566 expect(menu.limit()).toEqual(6);
567 menu.show();
Akronaba7a5a2016-08-15 21:58:33 +0200568 expect(menu.element().classList.contains('visible')).toBeTruthy();
Akronc1457bf2015-06-11 19:24:00 +0200569 expect(menu.item(0).active()).toBe(false);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000570 });
Nils Diewalda297f062015-04-02 00:23:46 +0000571 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000572
573 // table = view.toTable();
574 // table.sortBy('');
575 // table.element();
576 // tree = view.toTree();
577 // tree.element();
578
Nils Diewalda297f062015-04-02 00:23:46 +0000579});