blob: ab3a00fd1788dcac6eba5db2c03fb3e9511bbd28 [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
Akroncdb0baa2016-11-07 01:52:11 +0100149function matchElementReal () {
150 var me = document.createElement('em');
151 me.innerHTML =
152 '<li data-match-id="p85183-85184"' +
153 ' data-text-sigle="GOE/AGI/00000"' +
154 ' data-available-info="base/s=spans corenlp/c=spans corenlp/p=tokens corenlp/s=spans dereko/s=spans malt/d=rels opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans"' +
155 ' data-info="{&quot;UID&quot;:0,&quot;author&quot;:&quot;Goethe, Johann Wolfgang von&quot;,&quot;corpusID&quot;:null,&quot;corpusSigle&quot;:&quot;GOE&quot;,&quot;docID&quot;:null,&quot;docSigle&quot;:&quot;GOE\/AGI&quot;,&quot;layerInfos&quot;:&quot;base\/s=spans corenlp\/c=spans corenlp\/p=tokens corenlp\/s=spans dereko\/s=spans malt\/d=rels opennlp\/p=tokens opennlp\/s=spans tt\/l=tokens tt\/p=tokens tt\/s=spans&quot;,&quot;matchID&quot;:&quot;match-GOE\/AGI\/00000-p85183-85184&quot;,&quot;pubDate&quot;:&quot;1982&quot;,&quot;pubPlace&quot;:&quot;München&quot;,&quot;subTitle&quot;:&quot;Auch ich in Arkadien!&quot;,&quot;textID&quot;:null,&quot;textSigle&quot;:&quot;GOE\/AGI\/00000&quot;,&quot;title&quot;:&quot;Italienische Reise&quot;}"' +
156 ' id="GOE/AGI/00000#p85183-85184">' +
157 '<div>' +
158 '<div class="flag"></div>' +
159 '<div class="snippet startMore endMore"><span class="context-left"><span class="more"></span>keine großen Flächen, aber sanft gegeneinander laufende Berg- und Hügelrücken, durchgängig mit Weizen und Gerste bestellt, die eine ununterbrochene Masse von Fruchtbarkeit dem Auge darbieten. der diesen Pflanzen geeignete Boden wird so genutzt und so geschont, daß man nirgends einen </span><span class="match"><mark>Baum</mark></span><span class="context-right"> sieht, ja, alle die kleinen Ortschaften und Wohnungen liegen auf Rücken der Hügel, wo eine hinstreichende Reihe Kalkfelsen den Boden ohnehin unbrauchbar macht. dort wohnen die Weiber das ganze Jahr, mit Spinnen und Weben beschäftigt, die Männer hingegen bringen zur<span class="more"></span></span></div>' +
160 '</div>' +
161 '<p class="ref"><strong>Italienische Reise</strong> von Goethe, Johann Wolfgang von (<time datetime="1982">1982</time>) <span class="sigle">[GOE/AGI/00000]</span> </p>' +
162 '</li>';
163 return me.firstChild;
164};
Nils Diewalda297f062015-04-02 00:23:46 +0000165
Nils Diewald7c8ced22015-04-15 19:21:00 +0000166define(['match'], function () {
Nils Diewald58141332015-04-07 16:18:45 +0000167
Nils Diewald7c8ced22015-04-15 19:21:00 +0000168 // Override getMatchInfo API call
169 KorAP.API.getMatchInfo = function (x, param, cb) {
170 if (param['spans'] === undefined || param['spans'] === false)
171 cb({ "snippet": snippet });
172 else
173 cb({ "snippet": treeSnippet });
Nils Diewalda297f062015-04-02 00:23:46 +0000174 };
175
Nils Diewald7c8ced22015-04-15 19:21:00 +0000176 describe('KorAP.InfoLayer', function () {
177
178 var infoClass = require('match/infolayer');
Nils Diewalda297f062015-04-02 00:23:46 +0000179
Nils Diewald7c8ced22015-04-15 19:21:00 +0000180 it('should be initializable', function () {
181 expect(
182 function() { infoClass.create() }
183 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000184
Nils Diewald7c8ced22015-04-15 19:21:00 +0000185 expect(
186 function() { infoClass.create("base") }
187 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000188
Nils Diewald7c8ced22015-04-15 19:21:00 +0000189 var layer = infoClass.create("base", "s");
190 expect(layer).toBeTruthy();
191 expect(layer.foundry).toEqual("base");
192 expect(layer.layer).toEqual("s");
193 expect(layer.type).toEqual("tokens");
Nils Diewalda297f062015-04-02 00:23:46 +0000194
Nils Diewald7c8ced22015-04-15 19:21:00 +0000195 layer = infoClass.create("cnx", "syn", "spans");
196 expect(layer).toBeTruthy();
197 expect(layer.foundry).toEqual("cnx");
198 expect(layer.layer).toEqual("syn");
199 expect(layer.type).toEqual("spans");
Nils Diewald58141332015-04-07 16:18:45 +0000200 });
201 });
Nils Diewalda297f062015-04-02 00:23:46 +0000202
Nils Diewalda297f062015-04-02 00:23:46 +0000203
Nils Diewald7c8ced22015-04-15 19:21:00 +0000204 describe('KorAP.Match', function () {
205 var match = {
206 'corpusID' : 'WPD',
207 'docID' : 'UUU',
208 'textID' : '01912',
209 'matchID' : 'p121-122',
Akron0a6768f2016-07-13 18:00:43 +0200210 'textSigle' : 'WPD/UUU/01912',
Nils Diewald7c8ced22015-04-15 19:21:00 +0000211 'available' : available
212 };
213
214 var matchClass = require('match');
215
216 it('should be initializable by Object', function () {
217 expect(function() {
218 matchClass.create()
219 }).toThrow(new Error('Missing parameters'));
220
221 expect(matchClass.create(match)).toBeTruthy();
222
223 var m = matchClass.create(match);
Akron0a6768f2016-07-13 18:00:43 +0200224 expect(m.textSigle).toEqual("WPD/UUU/01912");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000225 expect(m.matchID).toEqual("p121-122");
226
227 // /corpus/WPD/UUU.01912/p121-122/matchInfo?spans=false&foundry=*
228 var m = matchClass.create(match);
229
230 // Spans:
231 var spans = m.getSpans();
232 expect(spans[0].foundry).toEqual("base");
233 expect(spans[0].layer).toEqual("s");
234
235 expect(spans[1].foundry).toEqual("corenlp");
236 expect(spans[1].layer).toEqual("c");
237
238 expect(spans[2].foundry).toEqual("corenlp");
239 expect(spans[2].layer).toEqual("s");
240
241 expect(spans[spans.length-1].foundry).toEqual("tt");
242 expect(spans[spans.length-1].layer).toEqual("s");
243
244 // Tokens:
245 var tokens = m.getTokens();
246 expect(tokens[0].foundry).toEqual("corenlp");
247 expect(tokens[0].layer).toEqual("ne");
248
249 expect(tokens[1].foundry).toEqual("corenlp");
250 expect(tokens[1].layer).toEqual("p");
251
252 expect(tokens[tokens.length-1].foundry).toEqual("tt");
253 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewald58141332015-04-07 16:18:45 +0000254 });
Nils Diewalda297f062015-04-02 00:23:46 +0000255
256
Akroncdb0baa2016-11-07 01:52:11 +0100257 it('should be initializable by Node 1', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000258 var m = matchClass.create(matchElementFactory());
Akron0a6768f2016-07-13 18:00:43 +0200259 expect(m.textSigle).toEqual("WPD/FFF/01460");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000260 expect(m.matchID).toEqual("p119-120");
Nils Diewalda297f062015-04-02 00:23:46 +0000261
Nils Diewald7c8ced22015-04-15 19:21:00 +0000262 // Spans:
263 var spans = m.getSpans();
264 expect(spans[0].foundry).toEqual("base");
265 expect(spans[0].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000266
Nils Diewald7c8ced22015-04-15 19:21:00 +0000267 expect(spans[1].foundry).toEqual("corenlp");
268 expect(spans[1].layer).toEqual("c");
Nils Diewalda297f062015-04-02 00:23:46 +0000269
Nils Diewald7c8ced22015-04-15 19:21:00 +0000270 expect(spans[2].foundry).toEqual("corenlp");
271 expect(spans[2].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000272
Nils Diewald7c8ced22015-04-15 19:21:00 +0000273 expect(spans[spans.length-1].foundry).toEqual("tt");
274 expect(spans[spans.length-1].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000275
Nils Diewald7c8ced22015-04-15 19:21:00 +0000276 // Tokens:
277 var tokens = m.getTokens();
278 expect(tokens[0].foundry).toEqual("corenlp");
279 expect(tokens[0].layer).toEqual("ne");
Nils Diewalda297f062015-04-02 00:23:46 +0000280
Nils Diewald7c8ced22015-04-15 19:21:00 +0000281 expect(tokens[1].foundry).toEqual("corenlp");
282 expect(tokens[1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000283
Nils Diewald7c8ced22015-04-15 19:21:00 +0000284 expect(tokens[tokens.length-1].foundry).toEqual("tt");
285 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000286
Nils Diewald7c8ced22015-04-15 19:21:00 +0000287 });
Nils Diewalda297f062015-04-02 00:23:46 +0000288
Akroncdb0baa2016-11-07 01:52:11 +0100289 it('should be initializable by Node 2', function () {
290 var ele = matchElementReal();
291 var m = matchClass.create(ele);
292 expect(m.textSigle).toEqual("GOE/AGI/00000");
293 expect(m.matchID).toEqual("p85183-85184");
294 });
295
296
Nils Diewald7c8ced22015-04-15 19:21:00 +0000297 it('should react to gui actions', function () {
298 var e = matchElementFactory();
Nils Diewalda297f062015-04-02 00:23:46 +0000299
Nils Diewald7c8ced22015-04-15 19:21:00 +0000300 expect(e.classList.contains('active')).toBe(false);
301 expect(e["_match"]).toBe(undefined);
Nils Diewalda297f062015-04-02 00:23:46 +0000302
Nils Diewald7c8ced22015-04-15 19:21:00 +0000303 var m = matchClass.create(e);
304
305 expect(e.classList.contains('active')).toBe(false);
306 expect(e["_match"]).not.toBe(undefined);
307
308 // Open the match
309 m.open();
310
311 expect(e.classList.contains('active')).toBe(true);
312 expect(e["_match"]).not.toBe(undefined);
313
314 // Close the match
315 m.close();
316 expect(e.classList.contains('active')).toBe(false);
317 expect(e["_match"]).not.toBe(undefined);
318
Nils Diewald58141332015-04-07 16:18:45 +0000319 });
320 });
Nils Diewalda297f062015-04-02 00:23:46 +0000321
Nils Diewald7c8ced22015-04-15 19:21:00 +0000322
323 describe('KorAP.MatchInfo', function () {
324
325 var matchClass = require('match');
326
327 var m = matchClass.create(match);
328 var info = m.info();
329
330 it('should contain a valid info', function () {
331 expect(m._info).toEqual(info);
332 });
333
334 var table1, table2;
335
336 // Async preparation
337 it('should fail to load a table async', function (done) {
338 expect(info).toBeTruthy();
339
340 info.getTable([], function (tablen) {
341 table1 = tablen;
342 done();
343 });
344 });
345
346 it('should\'nt be parsable (async)', function () {
347 expect(table1).not.toBeTruthy();
348 });
349
350 it('should load a working table async', function(done) {
351 expect(info).toBeTruthy();
352 info.getTable(undefined, function (tablem) {
353 table2 = tablem;
354 done();
355 });
356 });
357
358 it('should parse into a table (async)', function () {
359 expect(table2).toBeTruthy();
360
361 expect(table2.length()).toBe(3);
362
363 expect(table2.getToken(0)).toBe("meist");
364 expect(table2.getToken(1)).toBe("deutlich");
365 expect(table2.getToken(2)).toBe("leistungsfähiger");
366
367 expect(table2.getValue(0, "cnx", "p")[0]).toBe("ADV");
368 expect(table2.getValue(0, "cnx", "syn")[0]).toBe("@PREMOD");
369
370 expect(table2.getValue(2, "cnx", "l")[0]).toBe("fähig");
371 expect(table2.getValue(2, "cnx", "l")[1]).toBe("leistung");
372 });
373
374 it('should parse into a table view', function () {
375 var matchElement = matchElementFactory();
376 expect(matchElement.tagName).toEqual('LI');
377
378 // Match
379 expect(matchElement.children[0].tagName).toEqual('DIV');
380
381 // snippet
382 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
383 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
384 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
385
386 // reference
387 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
388 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
389
390 // not yet
391 expect(matchElement.children[0].children[1]).toBe(undefined);
392
393 var info = matchClass.create(matchElement).info();
394 info.toggle();
395
396 // Match
397 expect(matchElement.children[0].tagName).toEqual('DIV');
398
399 // snippet
400 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
401 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
402 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
403
404 // reference
405 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
406 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
407
408 // now
409 var infotable = matchElement.children[0].children[1];
410 expect(infotable.tagName).toEqual('DIV');
411 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
412
413 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
414 expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
415 });
416
417 var tree;
418 it('should parse into a tree (async) 1', function (done) {
419 var info = matchClass.create(match).info();
420 expect(info).toBeTruthy();
421 info.getTree(undefined, undefined, function (treem) {
Akron98a933f2016-08-11 00:19:17 +0200422 tree = treem;
423 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000424 });
425 });
426
427 it('should parse into a tree (async) 2', function () {
428 expect(tree).toBeTruthy();
429 expect(tree.nodes()).toEqual(49);
430 });
Nils Diewalda297f062015-04-02 00:23:46 +0000431
Akron98a933f2016-08-11 00:19:17 +0200432 var matchElement, info;
433 // var info, matchElement;
434 it('should parse into a tree view', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000435 matchElement = matchElementFactory();
436 expect(matchElement.tagName).toEqual('LI');
Nils Diewalda297f062015-04-02 00:23:46 +0000437
Nils Diewald7c8ced22015-04-15 19:21:00 +0000438 info = matchClass.create(matchElement).info();
439 info.toggle();
Nils Diewalda297f062015-04-02 00:23:46 +0000440
Nils Diewald7c8ced22015-04-15 19:21:00 +0000441 // Match
442 expect(matchElement.children[0].tagName).toEqual('DIV');
Nils Diewalda297f062015-04-02 00:23:46 +0000443
Nils Diewald7c8ced22015-04-15 19:21:00 +0000444 // snippet
445 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
446 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
447 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
Nils Diewalda297f062015-04-02 00:23:46 +0000448
Nils Diewald7c8ced22015-04-15 19:21:00 +0000449 // reference
450 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
451 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
Nils Diewalda297f062015-04-02 00:23:46 +0000452
Nils Diewald7c8ced22015-04-15 19:21:00 +0000453 // now
454 var infotable = matchElement.children[0].children[1];
455 expect(infotable.tagName).toEqual('DIV');
456 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
457 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
458 expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
459 });
Nils Diewalda297f062015-04-02 00:23:46 +0000460
Nils Diewald7c8ced22015-04-15 19:21:00 +0000461 it('should add a tree view async 1', function (done) {
462 expect(info).toBeTruthy();
463 info.addTree('mate', 'beebop', function () {
Akron98a933f2016-08-11 00:19:17 +0200464 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000465 });
466 });
467
468 it('should add a tree view async 2', function () {
469 // With added tree
470 var infotable = matchElement.children[0].children[1];
471 expect(infotable.tagName).toEqual('DIV');
472 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
473 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
474 expect(infotable.children[1].classList.contains('addtree')).toBe(false);
475
476 var tree = infotable.children[1];
477 expect(tree.tagName).toEqual('DIV');
478 expect(tree.classList.contains('matchtree')).toBeTruthy();
479 expect(tree.children[0].tagName).toEqual('H6');
480 expect(tree.children[0].children[0].tagName).toEqual('SPAN');
481 expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate');
482 expect(tree.children[0].children[1].tagName).toEqual('SPAN');
483 expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop');
484
485 expect(tree.children[1].tagName).toEqual('DIV');
Nils Diewald58141332015-04-07 16:18:45 +0000486 });
487 });
Nils Diewalda297f062015-04-02 00:23:46 +0000488
Nils Diewalda297f062015-04-02 00:23:46 +0000489
Nils Diewald7c8ced22015-04-15 19:21:00 +0000490 describe('KorAP.MatchTable', function () {
Nils Diewalda297f062015-04-02 00:23:46 +0000491
Nils Diewald7c8ced22015-04-15 19:21:00 +0000492 var matchClass = require('match');
Nils Diewalda297f062015-04-02 00:23:46 +0000493
Nils Diewald7c8ced22015-04-15 19:21:00 +0000494 var table;
495 it('should be retrieved async', function (done) {
496 var info = matchClass.create(match).info();
497 expect(info).toBeTruthy();
498 info.getTable(undefined, function (x) {
499 table = x;
500 done();
501 });
502 });
Nils Diewalda297f062015-04-02 00:23:46 +0000503
Nils Diewald7c8ced22015-04-15 19:21:00 +0000504 it('should be rendered async', function () {
505 var e = table.element();
506
507 expect(e.nodeName).toBe('TABLE');
508 expect(e.children[0].nodeName).toBe('THEAD');
509 var tr = e.children[0].children[0];
510 expect(tr.nodeName).toBe('TR');
511 expect(tr.children[0].nodeName).toBe('TH');
Nils Diewald58141332015-04-07 16:18:45 +0000512
Nils Diewald7c8ced22015-04-15 19:21:00 +0000513 expect(tr.children[0].firstChild.nodeValue).toBe('Foundry');
514 expect(tr.children[1].firstChild.nodeValue).toBe('Layer');
515 expect(tr.children[2].firstChild.nodeValue).toBe('meist');
516 expect(tr.children[3].firstChild.nodeValue).toBe('deutlich');
517 expect(tr.children[4].firstChild.nodeValue).toBe('leistungsfähiger');
518
519 // first row
520 tr = e.children[1].children[0];
521 expect(tr.nodeName).toBe('TR');
522 expect(tr.getAttribute('tabindex')).toEqual('0');
523 expect(tr.children[0].nodeName).toBe('TH');
524 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
525 expect(tr.children[1].firstChild.nodeValue).toEqual('l');
526 expect(tr.children[2].firstChild.nodeValue).toEqual('meist');
527 expect(tr.children[3].firstChild.nodeValue).toEqual('deutlich');
528 expect(tr.children[4].firstChild.nodeValue).toEqual('fähig');
529 expect(tr.children[4].lastChild.nodeValue).toEqual('leistung');
530
531 // second row
532 tr = e.children[1].children[1];
533 expect(tr.nodeName).toBe('TR');
534 expect(tr.getAttribute('tabindex')).toEqual('0');
535 expect(tr.children[0].nodeName).toBe('TH');
536 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
537 expect(tr.children[1].firstChild.nodeValue).toEqual('p');
538 expect(tr.children[2].firstChild.nodeValue).toEqual('ADV');
539 expect(tr.children[3].firstChild.nodeValue).toEqual('A');
540 expect(tr.children[4].firstChild.nodeValue).toEqual('A');
Nils Diewald58141332015-04-07 16:18:45 +0000541 });
542 });
Nils Diewalda297f062015-04-02 00:23:46 +0000543
Nils Diewald7c8ced22015-04-15 19:21:00 +0000544 describe('KorAP.MatchTree', function () {
545 var tree;
546 var matchClass = require('match');
Nils Diewalda297f062015-04-02 00:23:46 +0000547
Nils Diewald7c8ced22015-04-15 19:21:00 +0000548 it('should be rendered async 1', function (done) {
549 var info = matchClass.create(match).info();
550 expect(info).toBeTruthy();
551 info.getTree(undefined, undefined, function (y) {
552 tree = y;
553 done();
554 });
555 });
Nils Diewalda297f062015-04-02 00:23:46 +0000556
Nils Diewald7c8ced22015-04-15 19:21:00 +0000557 it('should be rendered async 2', function () {
558 var e = tree.element();
559 expect(e.nodeName).toEqual('svg');
560 expect(e.getElementsByTagName('g').length).toEqual(48);
Nils Diewald58141332015-04-07 16:18:45 +0000561 });
562 });
Nils Diewalda297f062015-04-02 00:23:46 +0000563
Nils Diewald7c8ced22015-04-15 19:21:00 +0000564
565 describe('KorAP.MatchTreeItem', function () {
566 var matchTreeItemClass = require('match/treeitem');
567 it('should be initializable', function () {
568 var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c'])
569 expect(mi.element().firstChild.nodeValue).toEqual('cnx/c');
570 expect(mi.lcField()).toEqual(' cnx/c');
571 expect(mi.foundry()).toEqual('cnx');
572 expect(mi.layer()).toEqual('c');
573 });
Nils Diewalda297f062015-04-02 00:23:46 +0000574 });
Nils Diewalda297f062015-04-02 00:23:46 +0000575
576
Nils Diewald7c8ced22015-04-15 19:21:00 +0000577 describe('KorAP.MatchTreeMenu', function () {
578 var matchTreeMenu = require('match/treemenu');
579 var matchTreeItem = require('match/treeitem');
580
581 it('should be initializable', function () {
582 var menu = matchTreeMenu.create(undefined, [
Akronaba7a5a2016-08-15 21:58:33 +0200583 ['cnx/c', 'cnx', 'c'],
584 ['xip/c', 'xip', 'c']
Nils Diewald7c8ced22015-04-15 19:21:00 +0000585 ]);
586
587 expect(menu.itemClass()).toEqual(matchTreeItem);
588 expect(menu.element().nodeName).toEqual('UL');
Akronaba7a5a2016-08-15 21:58:33 +0200589 expect(menu.element().classList.contains('visible')).toBeFalsy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000590 expect(menu.limit()).toEqual(6);
591 menu.show();
Akronaba7a5a2016-08-15 21:58:33 +0200592 expect(menu.element().classList.contains('visible')).toBeTruthy();
Akronc1457bf2015-06-11 19:24:00 +0200593 expect(menu.item(0).active()).toBe(false);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000594 });
Nils Diewalda297f062015-04-02 00:23:46 +0000595 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000596
597 // table = view.toTable();
598 // table.sortBy('');
599 // table.element();
600 // tree = view.toTree();
601 // tree.element();
602
Nils Diewalda297f062015-04-02 00:23:46 +0000603});