blob: 80690e5703d89f501a7c631985783d4c2f22e0a8 [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>" +
85 " <span title=\"xip/c:NP\">" +
86 " <span title=\"xip/c:PRON\">es</span>" +
87 " </span>" +
88 " <span title=\"xip/c:AP\">" +
89 " <span title=\"xip/c:ADV\">nun</span>" +
90 " <span title=\"xip/c:ADJ\">möglich</span>" +
91 " </span>" +
92 " <span title=\"xip/c:ADV\">z. B.</span>" +
93 " <span title=\"xip/c:NPA\">" +
94 " <span title=\"xip/c:NP\">" +
95 " <span title=\"xip/c:NOUN\">Voice</span>" +
96 " </span>" +
97 " </span>" + "(" +
98 " <span title=\"xip/c:INS\">" +
99 " <span title=\"xip/c:NPA\">" +
100 " <span title=\"xip/c:NP\">" +
101 " <span title=\"xip/c:NOUN\">Sprache</span>" +
102 " </span>" +
103 " </span>" +
104 " </span>" + ")" +
105 " <span title=\"xip/c:VERB\">bevorzugt</span>" +
106 " <span title=\"xip/c:PP\">" +
107 " <span title=\"xip/c:PREP\">in</span>" +
108 " <span title=\"xip/c:NP\">" +
109 " <span title=\"xip/c:PRON\">der</span>" +
110 " </span>" +
111 " <span title=\"xip/c:NPA\">" +
112 " <span title=\"xip/c:NP\">" +
113 " <span title=\"xip/c:NOUN\">Bridge</span>" +
114 " </span>" +
115 " </span>" +
116 " </span>" +
117 " <span title=\"xip/c:INFC\">" +
118 " <span title=\"xip/c:INS\">" +
119 " <span title=\"xip/c:VERB\">weiterzugeben</span>" +
120 " </span>" +
121 " </span>" +
122 " </span>" +
123 " </span>" +
124 "</span>" +
125 "<span class=\"context-right\"></span>";
126
127
128function matchElementFactory () {
129 var me = document.createElement('li');
130
131 me.setAttribute(
132 'data-available-info',
133 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' +
134 ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' +
135 ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' +
136 ' tt/p=tokens tt/s=spans');
137
138 me.setAttribute('data-corpus-id', 'WPD');
139 me.setAttribute('data-doc-id', 'FFF');
140 me.setAttribute('data-text-id', '01460');
Akron0a6768f2016-07-13 18:00:43 +0200141 me.setAttribute('data-text-sigle', 'WPD/FFF/01460');
Nils Diewalda297f062015-04-02 00:23:46 +0000142 me.setAttribute('data-match-id', 'p119-120');
143 me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>';
144 return me;
145};
146
147
Nils Diewald7c8ced22015-04-15 19:21:00 +0000148define(['match'], function () {
Nils Diewald58141332015-04-07 16:18:45 +0000149
Nils Diewald7c8ced22015-04-15 19:21:00 +0000150 // Override getMatchInfo API call
151 KorAP.API.getMatchInfo = function (x, param, cb) {
152 if (param['spans'] === undefined || param['spans'] === false)
153 cb({ "snippet": snippet });
154 else
155 cb({ "snippet": treeSnippet });
Nils Diewalda297f062015-04-02 00:23:46 +0000156 };
157
Nils Diewald7c8ced22015-04-15 19:21:00 +0000158 describe('KorAP.InfoLayer', function () {
159
160 var infoClass = require('match/infolayer');
Nils Diewalda297f062015-04-02 00:23:46 +0000161
Nils Diewald7c8ced22015-04-15 19:21:00 +0000162 it('should be initializable', function () {
163 expect(
164 function() { infoClass.create() }
165 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000166
Nils Diewald7c8ced22015-04-15 19:21:00 +0000167 expect(
168 function() { infoClass.create("base") }
169 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000170
Nils Diewald7c8ced22015-04-15 19:21:00 +0000171 var layer = infoClass.create("base", "s");
172 expect(layer).toBeTruthy();
173 expect(layer.foundry).toEqual("base");
174 expect(layer.layer).toEqual("s");
175 expect(layer.type).toEqual("tokens");
Nils Diewalda297f062015-04-02 00:23:46 +0000176
Nils Diewald7c8ced22015-04-15 19:21:00 +0000177 layer = infoClass.create("cnx", "syn", "spans");
178 expect(layer).toBeTruthy();
179 expect(layer.foundry).toEqual("cnx");
180 expect(layer.layer).toEqual("syn");
181 expect(layer.type).toEqual("spans");
Nils Diewald58141332015-04-07 16:18:45 +0000182 });
183 });
Nils Diewalda297f062015-04-02 00:23:46 +0000184
Nils Diewalda297f062015-04-02 00:23:46 +0000185
Nils Diewald7c8ced22015-04-15 19:21:00 +0000186 describe('KorAP.Match', function () {
187 var match = {
188 'corpusID' : 'WPD',
189 'docID' : 'UUU',
190 'textID' : '01912',
191 'matchID' : 'p121-122',
Akron0a6768f2016-07-13 18:00:43 +0200192 'textSigle' : 'WPD/UUU/01912',
Nils Diewald7c8ced22015-04-15 19:21:00 +0000193 'available' : available
194 };
195
196 var matchClass = require('match');
197
198 it('should be initializable by Object', function () {
199 expect(function() {
200 matchClass.create()
201 }).toThrow(new Error('Missing parameters'));
202
203 expect(matchClass.create(match)).toBeTruthy();
204
205 var m = matchClass.create(match);
Akron0a6768f2016-07-13 18:00:43 +0200206 expect(m.textSigle).toEqual("WPD/UUU/01912");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000207 expect(m.matchID).toEqual("p121-122");
208
209 // /corpus/WPD/UUU.01912/p121-122/matchInfo?spans=false&foundry=*
210 var m = matchClass.create(match);
211
212 // Spans:
213 var spans = m.getSpans();
214 expect(spans[0].foundry).toEqual("base");
215 expect(spans[0].layer).toEqual("s");
216
217 expect(spans[1].foundry).toEqual("corenlp");
218 expect(spans[1].layer).toEqual("c");
219
220 expect(spans[2].foundry).toEqual("corenlp");
221 expect(spans[2].layer).toEqual("s");
222
223 expect(spans[spans.length-1].foundry).toEqual("tt");
224 expect(spans[spans.length-1].layer).toEqual("s");
225
226 // Tokens:
227 var tokens = m.getTokens();
228 expect(tokens[0].foundry).toEqual("corenlp");
229 expect(tokens[0].layer).toEqual("ne");
230
231 expect(tokens[1].foundry).toEqual("corenlp");
232 expect(tokens[1].layer).toEqual("p");
233
234 expect(tokens[tokens.length-1].foundry).toEqual("tt");
235 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewald58141332015-04-07 16:18:45 +0000236 });
Nils Diewalda297f062015-04-02 00:23:46 +0000237
238
Nils Diewald7c8ced22015-04-15 19:21:00 +0000239 it('should be initializable by Node', function () {
240 var m = matchClass.create(matchElementFactory());
Akron0a6768f2016-07-13 18:00:43 +0200241 expect(m.textSigle).toEqual("WPD/FFF/01460");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000242 expect(m.matchID).toEqual("p119-120");
Nils Diewalda297f062015-04-02 00:23:46 +0000243
Nils Diewald7c8ced22015-04-15 19:21:00 +0000244 // Spans:
245 var spans = m.getSpans();
246 expect(spans[0].foundry).toEqual("base");
247 expect(spans[0].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000248
Nils Diewald7c8ced22015-04-15 19:21:00 +0000249 expect(spans[1].foundry).toEqual("corenlp");
250 expect(spans[1].layer).toEqual("c");
Nils Diewalda297f062015-04-02 00:23:46 +0000251
Nils Diewald7c8ced22015-04-15 19:21:00 +0000252 expect(spans[2].foundry).toEqual("corenlp");
253 expect(spans[2].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000254
Nils Diewald7c8ced22015-04-15 19:21:00 +0000255 expect(spans[spans.length-1].foundry).toEqual("tt");
256 expect(spans[spans.length-1].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000257
Nils Diewald7c8ced22015-04-15 19:21:00 +0000258 // Tokens:
259 var tokens = m.getTokens();
260 expect(tokens[0].foundry).toEqual("corenlp");
261 expect(tokens[0].layer).toEqual("ne");
Nils Diewalda297f062015-04-02 00:23:46 +0000262
Nils Diewald7c8ced22015-04-15 19:21:00 +0000263 expect(tokens[1].foundry).toEqual("corenlp");
264 expect(tokens[1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000265
Nils Diewald7c8ced22015-04-15 19:21:00 +0000266 expect(tokens[tokens.length-1].foundry).toEqual("tt");
267 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000268
Nils Diewald7c8ced22015-04-15 19:21:00 +0000269 });
Nils Diewalda297f062015-04-02 00:23:46 +0000270
Nils Diewald7c8ced22015-04-15 19:21:00 +0000271 it('should react to gui actions', function () {
272 var e = matchElementFactory();
Nils Diewalda297f062015-04-02 00:23:46 +0000273
Nils Diewald7c8ced22015-04-15 19:21:00 +0000274 expect(e.classList.contains('active')).toBe(false);
275 expect(e["_match"]).toBe(undefined);
Nils Diewalda297f062015-04-02 00:23:46 +0000276
Nils Diewald7c8ced22015-04-15 19:21:00 +0000277 var m = matchClass.create(e);
278
279 expect(e.classList.contains('active')).toBe(false);
280 expect(e["_match"]).not.toBe(undefined);
281
282 // Open the match
283 m.open();
284
285 expect(e.classList.contains('active')).toBe(true);
286 expect(e["_match"]).not.toBe(undefined);
287
288 // Close the match
289 m.close();
290 expect(e.classList.contains('active')).toBe(false);
291 expect(e["_match"]).not.toBe(undefined);
292
Nils Diewald58141332015-04-07 16:18:45 +0000293 });
294 });
Nils Diewalda297f062015-04-02 00:23:46 +0000295
Nils Diewald7c8ced22015-04-15 19:21:00 +0000296
297 describe('KorAP.MatchInfo', function () {
298
299 var matchClass = require('match');
300
301 var m = matchClass.create(match);
302 var info = m.info();
303
304 it('should contain a valid info', function () {
305 expect(m._info).toEqual(info);
306 });
307
308 var table1, table2;
309
310 // Async preparation
311 it('should fail to load a table async', function (done) {
312 expect(info).toBeTruthy();
313
314 info.getTable([], function (tablen) {
315 table1 = tablen;
316 done();
317 });
318 });
319
320 it('should\'nt be parsable (async)', function () {
321 expect(table1).not.toBeTruthy();
322 });
323
324 it('should load a working table async', function(done) {
325 expect(info).toBeTruthy();
326 info.getTable(undefined, function (tablem) {
327 table2 = tablem;
328 done();
329 });
330 });
331
332 it('should parse into a table (async)', function () {
333 expect(table2).toBeTruthy();
334
335 expect(table2.length()).toBe(3);
336
337 expect(table2.getToken(0)).toBe("meist");
338 expect(table2.getToken(1)).toBe("deutlich");
339 expect(table2.getToken(2)).toBe("leistungsfähiger");
340
341 expect(table2.getValue(0, "cnx", "p")[0]).toBe("ADV");
342 expect(table2.getValue(0, "cnx", "syn")[0]).toBe("@PREMOD");
343
344 expect(table2.getValue(2, "cnx", "l")[0]).toBe("fähig");
345 expect(table2.getValue(2, "cnx", "l")[1]).toBe("leistung");
346 });
347
348 it('should parse into a table view', function () {
349 var matchElement = matchElementFactory();
350 expect(matchElement.tagName).toEqual('LI');
351
352 // Match
353 expect(matchElement.children[0].tagName).toEqual('DIV');
354
355 // snippet
356 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
357 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
358 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
359
360 // reference
361 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
362 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
363
364 // not yet
365 expect(matchElement.children[0].children[1]).toBe(undefined);
366
367 var info = matchClass.create(matchElement).info();
368 info.toggle();
369
370 // Match
371 expect(matchElement.children[0].tagName).toEqual('DIV');
372
373 // snippet
374 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
375 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
376 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
377
378 // reference
379 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
380 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
381
382 // now
383 var infotable = matchElement.children[0].children[1];
384 expect(infotable.tagName).toEqual('DIV');
385 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
386
387 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
388 expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
389 });
390
391 var tree;
392 it('should parse into a tree (async) 1', function (done) {
393 var info = matchClass.create(match).info();
394 expect(info).toBeTruthy();
395 info.getTree(undefined, undefined, function (treem) {
396 tree = treem;
397 done();
398 });
399 });
400
401 it('should parse into a tree (async) 2', function () {
402 expect(tree).toBeTruthy();
403 expect(tree.nodes()).toEqual(49);
404 });
Nils Diewalda297f062015-04-02 00:23:46 +0000405
406
Nils Diewald7c8ced22015-04-15 19:21:00 +0000407 var info, matchElement;
408 it('should parse into a tree view', function () {
409 matchElement = matchElementFactory();
410 expect(matchElement.tagName).toEqual('LI');
Nils Diewalda297f062015-04-02 00:23:46 +0000411
Nils Diewald7c8ced22015-04-15 19:21:00 +0000412 info = matchClass.create(matchElement).info();
413 info.toggle();
Nils Diewalda297f062015-04-02 00:23:46 +0000414
Nils Diewald7c8ced22015-04-15 19:21:00 +0000415 // Match
416 expect(matchElement.children[0].tagName).toEqual('DIV');
Nils Diewalda297f062015-04-02 00:23:46 +0000417
Nils Diewald7c8ced22015-04-15 19:21:00 +0000418 // snippet
419 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
420 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
421 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
Nils Diewalda297f062015-04-02 00:23:46 +0000422
Nils Diewald7c8ced22015-04-15 19:21:00 +0000423 // reference
424 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
425 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
Nils Diewalda297f062015-04-02 00:23:46 +0000426
Nils Diewald7c8ced22015-04-15 19:21:00 +0000427 // now
428 var infotable = matchElement.children[0].children[1];
429 expect(infotable.tagName).toEqual('DIV');
430 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
431 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
432 expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
433 });
Nils Diewalda297f062015-04-02 00:23:46 +0000434
Nils Diewald7c8ced22015-04-15 19:21:00 +0000435 it('should add a tree view async 1', function (done) {
436 expect(info).toBeTruthy();
437 info.addTree('mate', 'beebop', function () {
438 done();
439 });
440 });
441
442 it('should add a tree view async 2', function () {
443 // With added tree
444 var infotable = matchElement.children[0].children[1];
445 expect(infotable.tagName).toEqual('DIV');
446 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
447 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
448 expect(infotable.children[1].classList.contains('addtree')).toBe(false);
449
450 var tree = infotable.children[1];
451 expect(tree.tagName).toEqual('DIV');
452 expect(tree.classList.contains('matchtree')).toBeTruthy();
453 expect(tree.children[0].tagName).toEqual('H6');
454 expect(tree.children[0].children[0].tagName).toEqual('SPAN');
455 expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate');
456 expect(tree.children[0].children[1].tagName).toEqual('SPAN');
457 expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop');
458
459 expect(tree.children[1].tagName).toEqual('DIV');
Nils Diewald58141332015-04-07 16:18:45 +0000460 });
461 });
Nils Diewalda297f062015-04-02 00:23:46 +0000462
Nils Diewalda297f062015-04-02 00:23:46 +0000463
Nils Diewald7c8ced22015-04-15 19:21:00 +0000464 describe('KorAP.MatchTable', function () {
Nils Diewalda297f062015-04-02 00:23:46 +0000465
Nils Diewald7c8ced22015-04-15 19:21:00 +0000466 var matchClass = require('match');
Nils Diewalda297f062015-04-02 00:23:46 +0000467
Nils Diewald7c8ced22015-04-15 19:21:00 +0000468 var table;
469 it('should be retrieved async', function (done) {
470 var info = matchClass.create(match).info();
471 expect(info).toBeTruthy();
472 info.getTable(undefined, function (x) {
473 table = x;
474 done();
475 });
476 });
Nils Diewalda297f062015-04-02 00:23:46 +0000477
Nils Diewald7c8ced22015-04-15 19:21:00 +0000478 it('should be rendered async', function () {
479 var e = table.element();
480
481 expect(e.nodeName).toBe('TABLE');
482 expect(e.children[0].nodeName).toBe('THEAD');
483 var tr = e.children[0].children[0];
484 expect(tr.nodeName).toBe('TR');
485 expect(tr.children[0].nodeName).toBe('TH');
Nils Diewald58141332015-04-07 16:18:45 +0000486
Nils Diewald7c8ced22015-04-15 19:21:00 +0000487 expect(tr.children[0].firstChild.nodeValue).toBe('Foundry');
488 expect(tr.children[1].firstChild.nodeValue).toBe('Layer');
489 expect(tr.children[2].firstChild.nodeValue).toBe('meist');
490 expect(tr.children[3].firstChild.nodeValue).toBe('deutlich');
491 expect(tr.children[4].firstChild.nodeValue).toBe('leistungsfähiger');
492
493 // first row
494 tr = e.children[1].children[0];
495 expect(tr.nodeName).toBe('TR');
496 expect(tr.getAttribute('tabindex')).toEqual('0');
497 expect(tr.children[0].nodeName).toBe('TH');
498 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
499 expect(tr.children[1].firstChild.nodeValue).toEqual('l');
500 expect(tr.children[2].firstChild.nodeValue).toEqual('meist');
501 expect(tr.children[3].firstChild.nodeValue).toEqual('deutlich');
502 expect(tr.children[4].firstChild.nodeValue).toEqual('fähig');
503 expect(tr.children[4].lastChild.nodeValue).toEqual('leistung');
504
505 // second row
506 tr = e.children[1].children[1];
507 expect(tr.nodeName).toBe('TR');
508 expect(tr.getAttribute('tabindex')).toEqual('0');
509 expect(tr.children[0].nodeName).toBe('TH');
510 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
511 expect(tr.children[1].firstChild.nodeValue).toEqual('p');
512 expect(tr.children[2].firstChild.nodeValue).toEqual('ADV');
513 expect(tr.children[3].firstChild.nodeValue).toEqual('A');
514 expect(tr.children[4].firstChild.nodeValue).toEqual('A');
Nils Diewald58141332015-04-07 16:18:45 +0000515 });
516 });
Nils Diewalda297f062015-04-02 00:23:46 +0000517
Nils Diewald7c8ced22015-04-15 19:21:00 +0000518 describe('KorAP.MatchTree', function () {
519 var tree;
520 var matchClass = require('match');
Nils Diewalda297f062015-04-02 00:23:46 +0000521
Nils Diewald7c8ced22015-04-15 19:21:00 +0000522 it('should be rendered async 1', function (done) {
523 var info = matchClass.create(match).info();
524 expect(info).toBeTruthy();
525 info.getTree(undefined, undefined, function (y) {
526 tree = y;
527 done();
528 });
529 });
Nils Diewalda297f062015-04-02 00:23:46 +0000530
Nils Diewald7c8ced22015-04-15 19:21:00 +0000531 it('should be rendered async 2', function () {
532 var e = tree.element();
533 expect(e.nodeName).toEqual('svg');
534 expect(e.getElementsByTagName('g').length).toEqual(48);
Nils Diewald58141332015-04-07 16:18:45 +0000535 });
536 });
Nils Diewalda297f062015-04-02 00:23:46 +0000537
Nils Diewald7c8ced22015-04-15 19:21:00 +0000538
539 describe('KorAP.MatchTreeItem', function () {
540 var matchTreeItemClass = require('match/treeitem');
541 it('should be initializable', function () {
542 var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c'])
543 expect(mi.element().firstChild.nodeValue).toEqual('cnx/c');
544 expect(mi.lcField()).toEqual(' cnx/c');
545 expect(mi.foundry()).toEqual('cnx');
546 expect(mi.layer()).toEqual('c');
547 });
Nils Diewalda297f062015-04-02 00:23:46 +0000548 });
Nils Diewalda297f062015-04-02 00:23:46 +0000549
550
Nils Diewald7c8ced22015-04-15 19:21:00 +0000551 describe('KorAP.MatchTreeMenu', function () {
552 var matchTreeMenu = require('match/treemenu');
553 var matchTreeItem = require('match/treeitem');
554
555 it('should be initializable', function () {
556 var menu = matchTreeMenu.create(undefined, [
557 ['cnx/c', 'cnx', 'c'],
558 ['xip/c', 'xip', 'c']
559 ]);
560
561 expect(menu.itemClass()).toEqual(matchTreeItem);
562 expect(menu.element().nodeName).toEqual('UL');
563 expect(menu.element().style.opacity).toEqual("0");
564 expect(menu.limit()).toEqual(6);
565 menu.show();
Akronc1457bf2015-06-11 19:24:00 +0200566 expect(menu.item(0).active()).toBe(false);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000567 });
Nils Diewalda297f062015-04-02 00:23:46 +0000568 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000569
570 // table = view.toTable();
571 // table.sortBy('');
572 // table.element();
573 // tree = view.toTree();
574 // tree.element();
575
Nils Diewalda297f062015-04-02 00:23:46 +0000576});