blob: 28eb8444a6d8e8f48a0f4392ccb809d4bda25900 [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',
26 'available' : available
27};
28
29var snippet = "<span title=\"cnx/l:meist\">" +
30 " <span title=\"cnx/p:ADV\">" +
31 " <span title=\"cnx/syn:@PREMOD\">" +
32 " <span title=\"mate/l:meist\">" +
33 " <span title=\"mate/p:ADV\">" +
34 " <span title=\"opennlp/p:ADV\">meist</span>" +
35 " </span>" +
36 " </span>" +
37 " </span>" +
38 " </span>" +
39 "</span>" +
40 "<span title=\"cnx/l:deutlich\">" +
41 " <span title=\"cnx/p:A\">" +
42 " <span title=\"cnx/syn:@PREMOD\">" +
43 " <span title=\"mate/l:deutlich\">" +
44 " <span title=\"mate/m:degree:pos\">" +
45 " <span title=\"mate/p:ADJD\">" +
46 " <span title=\"opennlp/p:ADJD\">deutlich</span>" +
47 " </span>" +
48 " </span>" +
49 " </span>" +
50 " </span>" +
51 " </span>" +
52 "</span>" +
53 "<span title=\"cnx/l:fähig\">" +
54 " <span title=\"cnx/l:leistung\">" +
55 " <span title=\"cnx/p:A\">" +
56 " <span title=\"cnx/syn:@NH\">" +
57 " <span title=\"mate/l:leistungsfähig\">" +
58 " <span title=\"mate/m:degree:comp\">" +
59 " <span title=\"mate/p:ADJD\">" +
60 " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" +
61 " </span>" +
62 " </span>" +
63 " </span>" +
64 " </span>" +
65 " </span>" +
66 " </span>" +
67 "</span>";
68
69var treeSnippet =
70 "<span class=\"context-left\"></span>" +
71 "<span class=\"match\">" +
72 " <span title=\"xip/c:MC\">" +
73 " <span title=\"xip/c:TOP\">" +
74 " <span title=\"xip/c:PP\">" +
75 " <span title=\"xip/c:PREP\">Mit</span>" +
76 " <span title=\"xip/c:NP\">" +
77 " <span title=\"xip/c:DET\">dieser</span>" +
78 " <span title=\"xip/c:NPA\">" +
79 " <span title=\"xip/c:NOUN\">Methode</span>" +
80 " </span>" +
81 " </span>" +
82 " </span>" +
83 " <span title=\"xip/c:VERB\">ist</span>" +
84 " <span title=\"xip/c:NP\">" +
85 " <span title=\"xip/c:PRON\">es</span>" +
86 " </span>" +
87 " <span title=\"xip/c:AP\">" +
88 " <span title=\"xip/c:ADV\">nun</span>" +
89 " <span title=\"xip/c:ADJ\">möglich</span>" +
90 " </span>" +
91 " <span title=\"xip/c:ADV\">z. B.</span>" +
92 " <span title=\"xip/c:NPA\">" +
93 " <span title=\"xip/c:NP\">" +
94 " <span title=\"xip/c:NOUN\">Voice</span>" +
95 " </span>" +
96 " </span>" + "(" +
97 " <span title=\"xip/c:INS\">" +
98 " <span title=\"xip/c:NPA\">" +
99 " <span title=\"xip/c:NP\">" +
100 " <span title=\"xip/c:NOUN\">Sprache</span>" +
101 " </span>" +
102 " </span>" +
103 " </span>" + ")" +
104 " <span title=\"xip/c:VERB\">bevorzugt</span>" +
105 " <span title=\"xip/c:PP\">" +
106 " <span title=\"xip/c:PREP\">in</span>" +
107 " <span title=\"xip/c:NP\">" +
108 " <span title=\"xip/c:PRON\">der</span>" +
109 " </span>" +
110 " <span title=\"xip/c:NPA\">" +
111 " <span title=\"xip/c:NP\">" +
112 " <span title=\"xip/c:NOUN\">Bridge</span>" +
113 " </span>" +
114 " </span>" +
115 " </span>" +
116 " <span title=\"xip/c:INFC\">" +
117 " <span title=\"xip/c:INS\">" +
118 " <span title=\"xip/c:VERB\">weiterzugeben</span>" +
119 " </span>" +
120 " </span>" +
121 " </span>" +
122 " </span>" +
123 "</span>" +
124 "<span class=\"context-right\"></span>";
125
126
127function matchElementFactory () {
128 var me = document.createElement('li');
129
130 me.setAttribute(
131 'data-available-info',
132 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' +
133 ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' +
134 ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' +
135 ' tt/p=tokens tt/s=spans');
136
137 me.setAttribute('data-corpus-id', 'WPD');
138 me.setAttribute('data-doc-id', 'FFF');
139 me.setAttribute('data-text-id', '01460');
140 me.setAttribute('data-match-id', 'p119-120');
141 me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>';
142 return me;
143};
144
145
Nils Diewald7c8ced22015-04-15 19:21:00 +0000146define(['match'], function () {
Nils Diewald58141332015-04-07 16:18:45 +0000147
Nils Diewald7c8ced22015-04-15 19:21:00 +0000148 // Override getMatchInfo API call
149 KorAP.API.getMatchInfo = function (x, param, cb) {
150 if (param['spans'] === undefined || param['spans'] === false)
151 cb({ "snippet": snippet });
152 else
153 cb({ "snippet": treeSnippet });
Nils Diewalda297f062015-04-02 00:23:46 +0000154 };
155
Nils Diewald7c8ced22015-04-15 19:21:00 +0000156 describe('KorAP.InfoLayer', function () {
157
158 var infoClass = require('match/infolayer');
Nils Diewalda297f062015-04-02 00:23:46 +0000159
Nils Diewald7c8ced22015-04-15 19:21:00 +0000160 it('should be initializable', function () {
161 expect(
162 function() { infoClass.create() }
163 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000164
Nils Diewald7c8ced22015-04-15 19:21:00 +0000165 expect(
166 function() { infoClass.create("base") }
167 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000168
Nils Diewald7c8ced22015-04-15 19:21:00 +0000169 var layer = infoClass.create("base", "s");
170 expect(layer).toBeTruthy();
171 expect(layer.foundry).toEqual("base");
172 expect(layer.layer).toEqual("s");
173 expect(layer.type).toEqual("tokens");
Nils Diewalda297f062015-04-02 00:23:46 +0000174
Nils Diewald7c8ced22015-04-15 19:21:00 +0000175 layer = infoClass.create("cnx", "syn", "spans");
176 expect(layer).toBeTruthy();
177 expect(layer.foundry).toEqual("cnx");
178 expect(layer.layer).toEqual("syn");
179 expect(layer.type).toEqual("spans");
Nils Diewald58141332015-04-07 16:18:45 +0000180 });
181 });
Nils Diewalda297f062015-04-02 00:23:46 +0000182
Nils Diewalda297f062015-04-02 00:23:46 +0000183
Nils Diewald7c8ced22015-04-15 19:21:00 +0000184 describe('KorAP.Match', function () {
185 var match = {
186 'corpusID' : 'WPD',
187 'docID' : 'UUU',
188 'textID' : '01912',
189 'matchID' : 'p121-122',
190 'available' : available
191 };
192
193 var matchClass = require('match');
194
195 it('should be initializable by Object', function () {
196 expect(function() {
197 matchClass.create()
198 }).toThrow(new Error('Missing parameters'));
199
200 expect(matchClass.create(match)).toBeTruthy();
201
202 var m = matchClass.create(match);
203 expect(m.corpusID).toEqual("WPD");
204 expect(m.docID).toEqual("UUU");
205 expect(m.textID).toEqual("01912");
206 expect(m.matchID).toEqual("p121-122");
207
208 // /corpus/WPD/UUU.01912/p121-122/matchInfo?spans=false&foundry=*
209 var m = matchClass.create(match);
210
211 // Spans:
212 var spans = m.getSpans();
213 expect(spans[0].foundry).toEqual("base");
214 expect(spans[0].layer).toEqual("s");
215
216 expect(spans[1].foundry).toEqual("corenlp");
217 expect(spans[1].layer).toEqual("c");
218
219 expect(spans[2].foundry).toEqual("corenlp");
220 expect(spans[2].layer).toEqual("s");
221
222 expect(spans[spans.length-1].foundry).toEqual("tt");
223 expect(spans[spans.length-1].layer).toEqual("s");
224
225 // Tokens:
226 var tokens = m.getTokens();
227 expect(tokens[0].foundry).toEqual("corenlp");
228 expect(tokens[0].layer).toEqual("ne");
229
230 expect(tokens[1].foundry).toEqual("corenlp");
231 expect(tokens[1].layer).toEqual("p");
232
233 expect(tokens[tokens.length-1].foundry).toEqual("tt");
234 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewald58141332015-04-07 16:18:45 +0000235 });
Nils Diewalda297f062015-04-02 00:23:46 +0000236
237
Nils Diewald7c8ced22015-04-15 19:21:00 +0000238 it('should be initializable by Node', function () {
239 var m = matchClass.create(matchElementFactory());
240 expect(m.corpusID).toEqual("WPD");
241 expect(m.docID).toEqual("FFF");
242 expect(m.textID).toEqual("01460");
243 expect(m.matchID).toEqual("p119-120");
Nils Diewalda297f062015-04-02 00:23:46 +0000244
Nils Diewald7c8ced22015-04-15 19:21:00 +0000245 // Spans:
246 var spans = m.getSpans();
247 expect(spans[0].foundry).toEqual("base");
248 expect(spans[0].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000249
Nils Diewald7c8ced22015-04-15 19:21:00 +0000250 expect(spans[1].foundry).toEqual("corenlp");
251 expect(spans[1].layer).toEqual("c");
Nils Diewalda297f062015-04-02 00:23:46 +0000252
Nils Diewald7c8ced22015-04-15 19:21:00 +0000253 expect(spans[2].foundry).toEqual("corenlp");
254 expect(spans[2].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000255
Nils Diewald7c8ced22015-04-15 19:21:00 +0000256 expect(spans[spans.length-1].foundry).toEqual("tt");
257 expect(spans[spans.length-1].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000258
Nils Diewald7c8ced22015-04-15 19:21:00 +0000259 // Tokens:
260 var tokens = m.getTokens();
261 expect(tokens[0].foundry).toEqual("corenlp");
262 expect(tokens[0].layer).toEqual("ne");
Nils Diewalda297f062015-04-02 00:23:46 +0000263
Nils Diewald7c8ced22015-04-15 19:21:00 +0000264 expect(tokens[1].foundry).toEqual("corenlp");
265 expect(tokens[1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000266
Nils Diewald7c8ced22015-04-15 19:21:00 +0000267 expect(tokens[tokens.length-1].foundry).toEqual("tt");
268 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000269
Nils Diewald7c8ced22015-04-15 19:21:00 +0000270 });
Nils Diewalda297f062015-04-02 00:23:46 +0000271
Nils Diewald7c8ced22015-04-15 19:21:00 +0000272 it('should react to gui actions', function () {
273 var e = matchElementFactory();
Nils Diewalda297f062015-04-02 00:23:46 +0000274
Nils Diewald7c8ced22015-04-15 19:21:00 +0000275 expect(e.classList.contains('active')).toBe(false);
276 expect(e["_match"]).toBe(undefined);
Nils Diewalda297f062015-04-02 00:23:46 +0000277
Nils Diewald7c8ced22015-04-15 19:21:00 +0000278 var m = matchClass.create(e);
279
280 expect(e.classList.contains('active')).toBe(false);
281 expect(e["_match"]).not.toBe(undefined);
282
283 // Open the match
284 m.open();
285
286 expect(e.classList.contains('active')).toBe(true);
287 expect(e["_match"]).not.toBe(undefined);
288
289 // Close the match
290 m.close();
291 expect(e.classList.contains('active')).toBe(false);
292 expect(e["_match"]).not.toBe(undefined);
293
Nils Diewald58141332015-04-07 16:18:45 +0000294 });
295 });
Nils Diewalda297f062015-04-02 00:23:46 +0000296
Nils Diewald7c8ced22015-04-15 19:21:00 +0000297
298 describe('KorAP.MatchInfo', function () {
299
300 var matchClass = require('match');
301
302 var m = matchClass.create(match);
303 var info = m.info();
304
305 it('should contain a valid info', function () {
306 expect(m._info).toEqual(info);
307 });
308
309 var table1, table2;
310
311 // Async preparation
312 it('should fail to load a table async', function (done) {
313 expect(info).toBeTruthy();
314
315 info.getTable([], function (tablen) {
316 table1 = tablen;
317 done();
318 });
319 });
320
321 it('should\'nt be parsable (async)', function () {
322 expect(table1).not.toBeTruthy();
323 });
324
325 it('should load a working table async', function(done) {
326 expect(info).toBeTruthy();
327 info.getTable(undefined, function (tablem) {
328 table2 = tablem;
329 done();
330 });
331 });
332
333 it('should parse into a table (async)', function () {
334 expect(table2).toBeTruthy();
335
336 expect(table2.length()).toBe(3);
337
338 expect(table2.getToken(0)).toBe("meist");
339 expect(table2.getToken(1)).toBe("deutlich");
340 expect(table2.getToken(2)).toBe("leistungsfähiger");
341
342 expect(table2.getValue(0, "cnx", "p")[0]).toBe("ADV");
343 expect(table2.getValue(0, "cnx", "syn")[0]).toBe("@PREMOD");
344
345 expect(table2.getValue(2, "cnx", "l")[0]).toBe("fähig");
346 expect(table2.getValue(2, "cnx", "l")[1]).toBe("leistung");
347 });
348
349 it('should parse into a table view', function () {
350 var matchElement = matchElementFactory();
351 expect(matchElement.tagName).toEqual('LI');
352
353 // Match
354 expect(matchElement.children[0].tagName).toEqual('DIV');
355
356 // snippet
357 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
358 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
359 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
360
361 // reference
362 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
363 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
364
365 // not yet
366 expect(matchElement.children[0].children[1]).toBe(undefined);
367
368 var info = matchClass.create(matchElement).info();
369 info.toggle();
370
371 // Match
372 expect(matchElement.children[0].tagName).toEqual('DIV');
373
374 // snippet
375 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
376 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
377 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
378
379 // reference
380 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
381 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
382
383 // now
384 var infotable = matchElement.children[0].children[1];
385 expect(infotable.tagName).toEqual('DIV');
386 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
387
388 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
389 expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
390 });
391
392 var tree;
393 it('should parse into a tree (async) 1', function (done) {
394 var info = matchClass.create(match).info();
395 expect(info).toBeTruthy();
396 info.getTree(undefined, undefined, function (treem) {
397 tree = treem;
398 done();
399 });
400 });
401
402 it('should parse into a tree (async) 2', function () {
403 expect(tree).toBeTruthy();
404 expect(tree.nodes()).toEqual(49);
405 });
Nils Diewalda297f062015-04-02 00:23:46 +0000406
407
Nils Diewald7c8ced22015-04-15 19:21:00 +0000408 var info, matchElement;
409 it('should parse into a tree view', function () {
410 matchElement = matchElementFactory();
411 expect(matchElement.tagName).toEqual('LI');
Nils Diewalda297f062015-04-02 00:23:46 +0000412
Nils Diewald7c8ced22015-04-15 19:21:00 +0000413 info = matchClass.create(matchElement).info();
414 info.toggle();
Nils Diewalda297f062015-04-02 00:23:46 +0000415
Nils Diewald7c8ced22015-04-15 19:21:00 +0000416 // Match
417 expect(matchElement.children[0].tagName).toEqual('DIV');
Nils Diewalda297f062015-04-02 00:23:46 +0000418
Nils Diewald7c8ced22015-04-15 19:21:00 +0000419 // snippet
420 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
421 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
422 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
Nils Diewalda297f062015-04-02 00:23:46 +0000423
Nils Diewald7c8ced22015-04-15 19:21:00 +0000424 // reference
425 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
426 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
Nils Diewalda297f062015-04-02 00:23:46 +0000427
Nils Diewald7c8ced22015-04-15 19:21:00 +0000428 // now
429 var infotable = matchElement.children[0].children[1];
430 expect(infotable.tagName).toEqual('DIV');
431 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
432 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
433 expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
434 });
Nils Diewalda297f062015-04-02 00:23:46 +0000435
Nils Diewald7c8ced22015-04-15 19:21:00 +0000436 it('should add a tree view async 1', function (done) {
437 expect(info).toBeTruthy();
438 info.addTree('mate', 'beebop', function () {
439 done();
440 });
441 });
442
443 it('should add a tree view async 2', function () {
444 // With added tree
445 var infotable = matchElement.children[0].children[1];
446 expect(infotable.tagName).toEqual('DIV');
447 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
448 expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy();
449 expect(infotable.children[1].classList.contains('addtree')).toBe(false);
450
451 var tree = infotable.children[1];
452 expect(tree.tagName).toEqual('DIV');
453 expect(tree.classList.contains('matchtree')).toBeTruthy();
454 expect(tree.children[0].tagName).toEqual('H6');
455 expect(tree.children[0].children[0].tagName).toEqual('SPAN');
456 expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate');
457 expect(tree.children[0].children[1].tagName).toEqual('SPAN');
458 expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop');
459
460 expect(tree.children[1].tagName).toEqual('DIV');
Nils Diewald58141332015-04-07 16:18:45 +0000461 });
462 });
Nils Diewalda297f062015-04-02 00:23:46 +0000463
Nils Diewalda297f062015-04-02 00:23:46 +0000464
Nils Diewald7c8ced22015-04-15 19:21:00 +0000465 describe('KorAP.MatchTable', function () {
Nils Diewalda297f062015-04-02 00:23:46 +0000466
Nils Diewald7c8ced22015-04-15 19:21:00 +0000467 var matchClass = require('match');
Nils Diewalda297f062015-04-02 00:23:46 +0000468
Nils Diewald7c8ced22015-04-15 19:21:00 +0000469 var table;
470 it('should be retrieved async', function (done) {
471 var info = matchClass.create(match).info();
472 expect(info).toBeTruthy();
473 info.getTable(undefined, function (x) {
474 table = x;
475 done();
476 });
477 });
Nils Diewalda297f062015-04-02 00:23:46 +0000478
Nils Diewald7c8ced22015-04-15 19:21:00 +0000479 it('should be rendered async', function () {
480 var e = table.element();
481
482 expect(e.nodeName).toBe('TABLE');
483 expect(e.children[0].nodeName).toBe('THEAD');
484 var tr = e.children[0].children[0];
485 expect(tr.nodeName).toBe('TR');
486 expect(tr.children[0].nodeName).toBe('TH');
Nils Diewald58141332015-04-07 16:18:45 +0000487
Nils Diewald7c8ced22015-04-15 19:21:00 +0000488 expect(tr.children[0].firstChild.nodeValue).toBe('Foundry');
489 expect(tr.children[1].firstChild.nodeValue).toBe('Layer');
490 expect(tr.children[2].firstChild.nodeValue).toBe('meist');
491 expect(tr.children[3].firstChild.nodeValue).toBe('deutlich');
492 expect(tr.children[4].firstChild.nodeValue).toBe('leistungsfähiger');
493
494 // first row
495 tr = e.children[1].children[0];
496 expect(tr.nodeName).toBe('TR');
497 expect(tr.getAttribute('tabindex')).toEqual('0');
498 expect(tr.children[0].nodeName).toBe('TH');
499 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
500 expect(tr.children[1].firstChild.nodeValue).toEqual('l');
501 expect(tr.children[2].firstChild.nodeValue).toEqual('meist');
502 expect(tr.children[3].firstChild.nodeValue).toEqual('deutlich');
503 expect(tr.children[4].firstChild.nodeValue).toEqual('fähig');
504 expect(tr.children[4].lastChild.nodeValue).toEqual('leistung');
505
506 // second row
507 tr = e.children[1].children[1];
508 expect(tr.nodeName).toBe('TR');
509 expect(tr.getAttribute('tabindex')).toEqual('0');
510 expect(tr.children[0].nodeName).toBe('TH');
511 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
512 expect(tr.children[1].firstChild.nodeValue).toEqual('p');
513 expect(tr.children[2].firstChild.nodeValue).toEqual('ADV');
514 expect(tr.children[3].firstChild.nodeValue).toEqual('A');
515 expect(tr.children[4].firstChild.nodeValue).toEqual('A');
Nils Diewald58141332015-04-07 16:18:45 +0000516 });
517 });
Nils Diewalda297f062015-04-02 00:23:46 +0000518
Nils Diewald7c8ced22015-04-15 19:21:00 +0000519 describe('KorAP.MatchTree', function () {
520 var tree;
521 var matchClass = require('match');
Nils Diewalda297f062015-04-02 00:23:46 +0000522
Nils Diewald7c8ced22015-04-15 19:21:00 +0000523 it('should be rendered async 1', function (done) {
524 var info = matchClass.create(match).info();
525 expect(info).toBeTruthy();
526 info.getTree(undefined, undefined, function (y) {
527 tree = y;
528 done();
529 });
530 });
Nils Diewalda297f062015-04-02 00:23:46 +0000531
Nils Diewald7c8ced22015-04-15 19:21:00 +0000532 it('should be rendered async 2', function () {
533 var e = tree.element();
534 expect(e.nodeName).toEqual('svg');
535 expect(e.getElementsByTagName('g').length).toEqual(48);
Nils Diewald58141332015-04-07 16:18:45 +0000536 });
537 });
Nils Diewalda297f062015-04-02 00:23:46 +0000538
Nils Diewald7c8ced22015-04-15 19:21:00 +0000539
540 describe('KorAP.MatchTreeItem', function () {
541 var matchTreeItemClass = require('match/treeitem');
542 it('should be initializable', function () {
543 var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c'])
544 expect(mi.element().firstChild.nodeValue).toEqual('cnx/c');
545 expect(mi.lcField()).toEqual(' cnx/c');
546 expect(mi.foundry()).toEqual('cnx');
547 expect(mi.layer()).toEqual('c');
548 });
Nils Diewalda297f062015-04-02 00:23:46 +0000549 });
Nils Diewalda297f062015-04-02 00:23:46 +0000550
551
Nils Diewald7c8ced22015-04-15 19:21:00 +0000552 describe('KorAP.MatchTreeMenu', function () {
553 var matchTreeMenu = require('match/treemenu');
554 var matchTreeItem = require('match/treeitem');
555
556 it('should be initializable', function () {
557 var menu = matchTreeMenu.create(undefined, [
558 ['cnx/c', 'cnx', 'c'],
559 ['xip/c', 'xip', 'c']
560 ]);
561
562 expect(menu.itemClass()).toEqual(matchTreeItem);
563 expect(menu.element().nodeName).toEqual('UL');
564 expect(menu.element().style.opacity).toEqual("0");
565 expect(menu.limit()).toEqual(6);
566 menu.show();
567 expect(menu.item(0).active()).toBe(true);
568 });
Nils Diewalda297f062015-04-02 00:23:46 +0000569 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000570
571 // table = view.toTable();
572 // table.sortBy('');
573 // table.element();
574 // tree = view.toTree();
575 // tree.element();
576
Nils Diewalda297f062015-04-02 00:23:46 +0000577});