blob: 08c0ced21ca3f28992e3efd67d16ab0bb407dd3e [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
Akrond8692de2018-07-26 13:06:01 +02003define(['match',
4 'view/match/tokentable',
5 'view/match/relations',
6 'panel/match',
7 'match/meta',
8 'match/infolayer',
9 'match/treeitem',
10 'match/treearc',
Akron3bdac532019-03-04 13:24:43 +010011 'match/treehierarchy',
Akrond8692de2018-07-26 13:06:01 +020012 'buttongroup/menu',
Akrona0ea3c32018-12-14 18:33:48 +010013 'match/attachement',
Akrond8692de2018-07-26 13:06:01 +020014 'hint/foundries/cnx',
15 'hint/foundries/mate'], function (
16 matchClass,
17 tableClass,
18 relClass,
19 panelClass,
20 metaClass,
21 infoClass,
22 matchTreeItemClass,
23 matchRelClass,
Akron3bdac532019-03-04 13:24:43 +010024 matchHierClass,
Akrona0ea3c32018-12-14 18:33:48 +010025 matchTreeMenuClass,
26 attachementClass) {
Nils Diewald7c8ced22015-04-15 19:21:00 +000027
Akrond8692de2018-07-26 13:06:01 +020028 var available = [
29 'base/s=spans',
30 'corenlp/c=spans',
31 'corenlp/ne=tokens',
32 'corenlp/p=tokens',
33 'corenlp/s=spans',
34 'glemm/l=tokens',
35 'mate/l=tokens',
36 'mate/m=tokens',
37 'mate/p=tokens',
38 'opennlp/p=tokens',
39 'opennlp/s=spans',
40 'tt/l=tokens',
41 'tt/p=tokens',
42 'tt/s=spans'
43 ];
Nils Diewalda297f062015-04-02 00:23:46 +000044
Akrond8692de2018-07-26 13:06:01 +020045 var match = {
46 'corpusID' : 'WPD',
47 'docID' : 'UUU',
48 'textID' : '01912',
49 'matchID' : 'p121-122',
50 'textSigle' : 'WPD/UUU/01912',
51 'available' : available
Nils Diewalda297f062015-04-02 00:23:46 +000052 };
Akrond8692de2018-07-26 13:06:01 +020053
54
55 var fields = [
56 {
57 "@type": "koral:field",
58 "key": "author",
59 "type": "type:text",
60 "value": "Sprachpfleger, u.a."
61 },
62 {
63 "@type": "koral:field",
64 "key": "textClass",
Akrond45a1702018-11-19 18:15:17 +010065 "type": "type:keywords", // May not be necessary
Akrond8692de2018-07-26 13:06:01 +020066 "value": ["kultur", "film"]
67 },
68 {
69 "@type":"koral:field",
70 "key":"foundries",
71 "type":"type:string",
72 "value":[
73 "corenlp",
74 "corenlp\/constituency",
75 "corenlp\/morpho",
76 "corenlp\/sentences",
77 "dereko",
78 "dereko\/structure",
79 "dereko\/structure\/base-sentences-paragraphs-pagebreaks",
80 "opennlp",
81 "opennlp\/morpho",
82 "opennlp\/sentences"
83 ]
Akrona0ea3c32018-12-14 18:33:48 +010084 },
85 {
86 "@type": "koral:field",
87 "key": "xlink",
88 "type": "type:attachement",
89 "value": "data:application/x.korap-link;title=Cool,https://de.wikipedia.org/wiki/Beispiel"
90 },
Akrond3bb85b2019-02-08 10:15:13 +010091 {
92 "@type": "koral:field",
93 "key": "z-reference",
94 "type": "type:attachement",
95 "value": "data:,This is a reference"
96 }
Akrond8692de2018-07-26 13:06:01 +020097 ];
98
99
Akron5dc31172019-05-15 18:43:48 +0200100 var snippet = "<span class=\"context-left\"><\/span>"+
101 "<span class=\"match\">" +
Akron1a780fe2019-05-21 15:59:00 +0200102 "<span class=\"cutted\"><\/span>" +
103 "Außerdem " +
Akron5dc31172019-05-15 18:43:48 +0200104 "<span title=\"cnx/l:meist\">" +
Akrond8692de2018-07-26 13:06:01 +0200105 " <span title=\"cnx/p:ADV\">" +
106 " <span title=\"cnx/syn:@PREMOD\">" +
107 " <span title=\"mate/l:meist\">" +
108 " <span title=\"mate/l:meist\">" +
109 " <span title=\"mate/p:ADV\">" +
110 " <span title=\"opennlp/p:ADV\">meist</span>" +
111 " </span>" +
112 " </span>" +
113 " </span>" +
114 " </span>" +
115 " </span>" +
116 "</span>" +
Akronad1e46a2018-09-19 15:55:40 +0200117 "<mark>" +
Akrond8692de2018-07-26 13:06:01 +0200118 "<span title=\"cnx/l:deutlich\">" +
119 " <span title=\"cnx/p:A\">" +
120 " <span title=\"cnx/syn:@PREMOD\">" +
121 " <span title=\"mate/l:deutlich\">" +
122 " <span title=\"mate/m:degree:pos\">" +
123 " <span title=\"mate/p:ADJD\">" +
124 " <span title=\"opennlp/p:ADJD\">deutlich</span>" +
125 " </span>" +
126 " </span>" +
127 " </span>" +
128 " </span>" +
129 " </span>" +
130 "</span>" +
Akronad1e46a2018-09-19 15:55:40 +0200131 "</mark>" +
Akron158fce12019-12-17 14:43:29 +0100132 "<span title=\"dgd/para:incident\">▮</span>" +
Akrond8692de2018-07-26 13:06:01 +0200133 "<span title=\"cnx/l:fähig\">" +
134 " <span title=\"cnx/l:leistung\">" +
135 " <span title=\"cnx/p:A\">" +
136 " <span title=\"cnx/p:ADJA\">" +
137 " <span title=\"cnx/syn:@NH\">" +
138 " <span title=\"mate/l:leistungsfähig\">" +
139 " <span title=\"mate/m:degree:comp\">" +
140 " <span title=\"mate/p:ADJD\">" +
141 " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" +
142 " </span>" +
143 " </span>" +
144 " </span>" +
145 " </span>" +
146 " </span>" +
147 " </span>" +
148 " </span>" +
Akron5dc31172019-05-15 18:43:48 +0200149 "</span>" +
150 " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können." +
151 "<span class=\"cutted\"><\/span>" +
Akrond8692de2018-07-26 13:06:01 +0200152 "</span>";
153
154 var treeSnippet =
155 "<span class=\"context-left\"></span>" +
156 "<span class=\"match\">" +
157 " <span title=\"xip/c:MC\">" +
158 " <span title=\"xip/c:TOP\">" +
159 " <span title=\"xip/c:PP\">" +
160 " <span title=\"xip/c:PREP\">Mit</span>" +
161 " <span title=\"xip/c:NP\">" +
162 " <span title=\"xip/c:DET\">dieser</span>" +
163 " <span title=\"xip/c:NPA\">" +
164 " <span title=\"xip/c:NOUN\">Methode</span>" +
165 " </span>" +
166 " </span>" +
167 " </span>" +
168 " <span title=\"xip/c:VERB\">ist</span>" +
169 " <mark>" +
170 " <span title=\"xip/c:NP\">" +
171 " <span title=\"xip/c:PRON\">es</span>" +
172 " </span>" +
173 " <span title=\"xip/c:AP\">" +
174 " <span title=\"xip/c:ADV\">nun</span>" +
175 " <span title=\"xip/c:ADJ\">möglich</span>" +
176 " </span>" +
177 " </mark>" +
178 " <span title=\"xip/c:ADV\">z. B.</span>" +
179 " <span title=\"xip/c:NPA\">" +
180 " <span title=\"xip/c:NP\">" +
181 " <span title=\"xip/c:NOUN\">Voice</span>" +
182 " </span>" +
183 " </span>" + "(" +
184 " <span title=\"xip/c:INS\">" +
185 " <span title=\"xip/c:NPA\">" +
186 " <span title=\"xip/c:NP\">" +
187 " <span title=\"xip/c:NOUN\">Sprache</span>" +
188 " </span>" +
189 " </span>" +
190 " </span>" + ")" +
191 " <span title=\"xip/c:VERB\">bevorzugt</span>" +
192 " <span title=\"xip/c:PP\">" +
193 " <span title=\"xip/c:PREP\">in</span>" +
194 " <span title=\"xip/c:NP\">" +
195 " <span title=\"xip/c:PRON\">der</span>" +
196 " </span>" +
197 " <span title=\"xip/c:NPA\">" +
198 " <span title=\"xip/c:NP\">" +
199 " <span title=\"xip/c:NOUN\">Bridge</span>" +
200 " </span>" +
201 " </span>" +
202 " </span>" +
203 " <span title=\"xip/c:INFC\">" +
204 " <span title=\"xip/c:INS\">" +
205 " <span title=\"xip/c:VERB\">weiterzugeben</span>" +
206 " </span>" +
207 " </span>" +
208 " </span>" +
209 " </span>" +
210 "</span>" +
211 "<span class=\"context-right\"></span>";
212
Akron3bdac532019-03-04 13:24:43 +0100213 var treeSnippetHierarchy =
214 "<span class=\"context-left\"><\/span><span class=\"match\"><span title=\"corenlp\/c:MPN\">Leonard Maltin<\/span> schrieb: „<span title=\"corenlp\/c:S\"><span title=\"corenlp\/c:NP\">Plot <span title=\"corenlp\/c:MPN\">contrivance isn‘<mark>t<\/mark> handled badly<\/span><\/span> <span title=\"corenlp\/c:PP\">in above-average programmer<\/span><\/span>“.&lt;<span title=\"corenlp\/c:S\"><span title=\"corenlp\/c:ROOT\"><span title=\"corenlp\/c:NP\">ref&gt;''<span title=\"corenlp\/c:NP\"><span title=\"corenlp\/c:CNP\">Movie &amp;amp; Video<\/span> Guide<\/span><\/span>'', <span title=\"corenlp\/c:VP\">1996 edition, <span title=\"corenlp\/c:NP\"><span title=\"corenlp\/c:CNP\">S. 210<\/span><\/span><\/span>.<\/span><\/span><\/span><span class=\"context-right\"><\/span>";
Akrond8692de2018-07-26 13:06:01 +0200215
Akron158fce12019-12-17 14:43:29 +0100216 function matchElementFactory () {
Akrond8692de2018-07-26 13:06:01 +0200217 var me = document.createElement('li');
218
219 me.setAttribute(
220 'data-available-info',
221 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' +
222 ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' +
223 ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' +
224 ' tt/p=tokens tt/s=spans');
225
226 me.setAttribute('data-corpus-id', 'WPD');
227 me.setAttribute('data-doc-id', 'FFF');
228 me.setAttribute('data-text-id', '01460');
229 me.setAttribute('data-text-sigle', 'WPD/FFF/01460');
230 me.setAttribute('data-match-id', 'p119-120');
231 me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>';
232 return me;
233 };
234
235 function matchElementReal () {
236 var me = document.createElement('em');
237 me.innerHTML =
238 '<li data-match-id="p85183-85184"' +
239 ' data-text-sigle="GOE/AGI/00000"' +
240 ' 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"' +
241 ' 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;}"' +
242 ' id="GOE/AGI/00000#p85183-85184">' +
243 '<div>' +
244 '<div class="flag"></div>' +
245 '<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>' +
246 '</div>' +
247 '<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>' +
248 '</li>';
249 return me.firstChild;
250 };
251
252 var beforeAllFunc = function () {
253 // Override getMatchInfo API call
254 KorAP.API.getMatchInfo = function (x, param, cb) {
255 if (param['spans'] === undefined || param['spans'] === false)
256 cb({ "snippet": snippet });
257 else
258 cb({ "snippet": treeSnippet });
259 };
260 };
261
262 var afterAllFunc = function () {
263 KorAP.API.getMatchInfo = undefined;
hebasta87f1b1f2019-07-30 13:03:23 +0200264 KorAP.TreeMenu = undefined;
Akrond8692de2018-07-26 13:06:01 +0200265 var body = document.body;
hebasta87f1b1f2019-07-30 13:03:23 +0200266 var i = body.children.length - 1;
267 while (i >= 0) {
Akrond8692de2018-07-26 13:06:01 +0200268 if (body.children[i].nodeType && body.children[i].nodeType === 1) {
269 if (!body.children[i].classList.contains("jasmine_html-reporter")) {
270 body.removeChild(body.children[i]);
271 };
272 };
hebasta87f1b1f2019-07-30 13:03:23 +0200273 i--;
Akrond8692de2018-07-26 13:06:01 +0200274 };
275 };
Akron671fdb92017-09-12 18:09:46 +0200276
Nils Diewald7c8ced22015-04-15 19:21:00 +0000277 describe('KorAP.InfoLayer', function () {
Akrond8692de2018-07-26 13:06:01 +0200278 beforeAll(beforeAllFunc);
279 afterAll(afterAllFunc);
Nils Diewalda297f062015-04-02 00:23:46 +0000280
Nils Diewald7c8ced22015-04-15 19:21:00 +0000281 it('should be initializable', function () {
282 expect(
Akron671fdb92017-09-12 18:09:46 +0200283 function() { infoClass.create() }
Nils Diewald7c8ced22015-04-15 19:21:00 +0000284 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000285
Nils Diewald7c8ced22015-04-15 19:21:00 +0000286 expect(
Akron671fdb92017-09-12 18:09:46 +0200287 function() { infoClass.create("base") }
Nils Diewald7c8ced22015-04-15 19:21:00 +0000288 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000289
Nils Diewald7c8ced22015-04-15 19:21:00 +0000290 var layer = infoClass.create("base", "s");
291 expect(layer).toBeTruthy();
292 expect(layer.foundry).toEqual("base");
293 expect(layer.layer).toEqual("s");
294 expect(layer.type).toEqual("tokens");
Nils Diewalda297f062015-04-02 00:23:46 +0000295
Nils Diewald7c8ced22015-04-15 19:21:00 +0000296 layer = infoClass.create("cnx", "syn", "spans");
297 expect(layer).toBeTruthy();
298 expect(layer.foundry).toEqual("cnx");
299 expect(layer.layer).toEqual("syn");
300 expect(layer.type).toEqual("spans");
Nils Diewald58141332015-04-07 16:18:45 +0000301 });
302 });
Nils Diewalda297f062015-04-02 00:23:46 +0000303
Nils Diewalda297f062015-04-02 00:23:46 +0000304
Nils Diewald7c8ced22015-04-15 19:21:00 +0000305 describe('KorAP.Match', function () {
Akrond8692de2018-07-26 13:06:01 +0200306 beforeAll(beforeAllFunc);
307 afterAll(afterAllFunc);
308
Nils Diewald7c8ced22015-04-15 19:21:00 +0000309 var match = {
310 'corpusID' : 'WPD',
311 'docID' : 'UUU',
312 'textID' : '01912',
313 'matchID' : 'p121-122',
Akron0a6768f2016-07-13 18:00:43 +0200314 'textSigle' : 'WPD/UUU/01912',
Nils Diewald7c8ced22015-04-15 19:21:00 +0000315 'available' : available
316 };
317
Nils Diewald7c8ced22015-04-15 19:21:00 +0000318 it('should be initializable by Object', function () {
319 expect(function() {
Akron671fdb92017-09-12 18:09:46 +0200320 matchClass.create()
Nils Diewald7c8ced22015-04-15 19:21:00 +0000321 }).toThrow(new Error('Missing parameters'));
322
323 expect(matchClass.create(match)).toBeTruthy();
324
325 var m = matchClass.create(match);
Akron0a6768f2016-07-13 18:00:43 +0200326 expect(m.textSigle).toEqual("WPD/UUU/01912");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000327 expect(m.matchID).toEqual("p121-122");
328
329 // /corpus/WPD/UUU.01912/p121-122/matchInfo?spans=false&foundry=*
330 var m = matchClass.create(match);
331
332 // Spans:
333 var spans = m.getSpans();
334 expect(spans[0].foundry).toEqual("base");
335 expect(spans[0].layer).toEqual("s");
336
337 expect(spans[1].foundry).toEqual("corenlp");
338 expect(spans[1].layer).toEqual("c");
339
340 expect(spans[2].foundry).toEqual("corenlp");
341 expect(spans[2].layer).toEqual("s");
342
343 expect(spans[spans.length-1].foundry).toEqual("tt");
344 expect(spans[spans.length-1].layer).toEqual("s");
345
346 // Tokens:
347 var tokens = m.getTokens();
348 expect(tokens[0].foundry).toEqual("corenlp");
349 expect(tokens[0].layer).toEqual("ne");
350
351 expect(tokens[1].foundry).toEqual("corenlp");
352 expect(tokens[1].layer).toEqual("p");
353
354 expect(tokens[tokens.length-1].foundry).toEqual("tt");
355 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewald58141332015-04-07 16:18:45 +0000356 });
Nils Diewalda297f062015-04-02 00:23:46 +0000357
358
Akroncdb0baa2016-11-07 01:52:11 +0100359 it('should be initializable by Node 1', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000360 var m = matchClass.create(matchElementFactory());
Akron0a6768f2016-07-13 18:00:43 +0200361 expect(m.textSigle).toEqual("WPD/FFF/01460");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000362 expect(m.matchID).toEqual("p119-120");
Nils Diewalda297f062015-04-02 00:23:46 +0000363
Nils Diewald7c8ced22015-04-15 19:21:00 +0000364 // Spans:
365 var spans = m.getSpans();
366 expect(spans[0].foundry).toEqual("base");
367 expect(spans[0].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000368
Nils Diewald7c8ced22015-04-15 19:21:00 +0000369 expect(spans[1].foundry).toEqual("corenlp");
370 expect(spans[1].layer).toEqual("c");
Nils Diewalda297f062015-04-02 00:23:46 +0000371
Nils Diewald7c8ced22015-04-15 19:21:00 +0000372 expect(spans[2].foundry).toEqual("corenlp");
373 expect(spans[2].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000374
Nils Diewald7c8ced22015-04-15 19:21:00 +0000375 expect(spans[spans.length-1].foundry).toEqual("tt");
376 expect(spans[spans.length-1].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000377
Nils Diewald7c8ced22015-04-15 19:21:00 +0000378 // Tokens:
379 var tokens = m.getTokens();
380 expect(tokens[0].foundry).toEqual("corenlp");
381 expect(tokens[0].layer).toEqual("ne");
Nils Diewalda297f062015-04-02 00:23:46 +0000382
Nils Diewald7c8ced22015-04-15 19:21:00 +0000383 expect(tokens[1].foundry).toEqual("corenlp");
384 expect(tokens[1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000385
Nils Diewald7c8ced22015-04-15 19:21:00 +0000386 expect(tokens[tokens.length-1].foundry).toEqual("tt");
387 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000388
Nils Diewald7c8ced22015-04-15 19:21:00 +0000389 });
Nils Diewalda297f062015-04-02 00:23:46 +0000390
Akroncdb0baa2016-11-07 01:52:11 +0100391 it('should be initializable by Node 2', function () {
392 var ele = matchElementReal();
393 var m = matchClass.create(ele);
394 expect(m.textSigle).toEqual("GOE/AGI/00000");
395 expect(m.matchID).toEqual("p85183-85184");
396 });
397
398
Nils Diewald7c8ced22015-04-15 19:21:00 +0000399 it('should react to gui actions', function () {
400 var e = matchElementFactory();
Nils Diewalda297f062015-04-02 00:23:46 +0000401
Nils Diewald7c8ced22015-04-15 19:21:00 +0000402 expect(e.classList.contains('active')).toBe(false);
403 expect(e["_match"]).toBe(undefined);
Nils Diewalda297f062015-04-02 00:23:46 +0000404
Nils Diewald7c8ced22015-04-15 19:21:00 +0000405 var m = matchClass.create(e);
406
407 expect(e.classList.contains('active')).toBe(false);
408 expect(e["_match"]).not.toBe(undefined);
hebasta87f1b1f2019-07-30 13:03:23 +0200409
Nils Diewald7c8ced22015-04-15 19:21:00 +0000410 // Open the match
411 m.open();
hebasta87f1b1f2019-07-30 13:03:23 +0200412
Nils Diewald7c8ced22015-04-15 19:21:00 +0000413 expect(e.classList.contains('active')).toBe(true);
414 expect(e["_match"]).not.toBe(undefined);
415
Akronbfe912c2018-07-17 19:30:52 +0200416 actions = e.querySelector("p.ref > div.action.button-group").children;
Akrond141a362018-07-10 18:12:13 +0200417
Akronbfe912c2018-07-17 19:30:52 +0200418 expect(actions[0].getAttribute("class")).toEqual("metatable");
Akronc296ca22018-04-24 16:35:26 +0200419 expect(actions[1].getAttribute("class")).toEqual("info");
420 expect(actions[2].getAttribute("class")).toEqual("tree");
421
Nils Diewald7c8ced22015-04-15 19:21:00 +0000422 // Close the match
Akronec6bb8e2018-08-29 13:07:56 +0200423 m.minimize();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000424 expect(e.classList.contains('active')).toBe(false);
425 expect(e["_match"]).not.toBe(undefined);
Nils Diewald58141332015-04-07 16:18:45 +0000426 });
Nils Diewalda297f062015-04-02 00:23:46 +0000427
Akrond8692de2018-07-26 13:06:01 +0200428 it('should open tree menu', function () {
Akronc296ca22018-04-24 16:35:26 +0200429 var e = matchElementFactory();
430 var m = matchClass.create(e);
431 m.open();
Akronbfe912c2018-07-17 19:30:52 +0200432 var relation = e.querySelector("p.ref > div.action.button-group > span:nth-of-type(3)");
Akronc296ca22018-04-24 16:35:26 +0200433 expect(relation.getAttribute("class")).toEqual("tree");
Akron52ed22d2018-07-11 17:05:19 +0200434 expect(document.getElementsByClassName("button-group-list").length).toEqual(0);
Akronc296ca22018-04-24 16:35:26 +0200435 expect(document.activeElement.tagName).toEqual("BODY");
hebasta87f1b1f2019-07-30 13:03:23 +0200436
Akronc296ca22018-04-24 16:35:26 +0200437 // Show menu
438 relation.click();
Akron52ed22d2018-07-11 17:05:19 +0200439 expect(document.getElementsByClassName("button-group-list").length).toEqual(1);
Akronc296ca22018-04-24 16:35:26 +0200440 expect(document.activeElement.tagName).toEqual("UL");
hebasta87f1b1f2019-07-30 13:03:23 +0200441
Akronc296ca22018-04-24 16:35:26 +0200442 // Choose first tree
Akron52ed22d2018-07-11 17:05:19 +0200443 document.getElementsByClassName("button-group-list")[0].getElementsByTagName("li")[1].click();
Akronc296ca22018-04-24 16:35:26 +0200444 expect(e.querySelector("div.matchinfo div.matchtree h6 span").innerText).toEqual("corenlp");
445
446 // This should blur the focus
447 expect(document.activeElement.tagName).toEqual("BODY");
hebasta87f1b1f2019-07-30 13:03:23 +0200448
Akronc296ca22018-04-24 16:35:26 +0200449 });
450
451 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000452
Akron7f9a6a32018-07-18 15:05:23 +0200453 describe('KorAP.TableView', function () {
Akrond8692de2018-07-26 13:06:01 +0200454 beforeAll(beforeAllFunc);
455 afterAll(afterAllFunc);
Akron5dc31172019-05-15 18:43:48 +0200456
457 let longString = " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können.";
458
Akron7f9a6a32018-07-18 15:05:23 +0200459 var table;
Nils Diewald7c8ced22015-04-15 19:21:00 +0000460
Akron7f9a6a32018-07-18 15:05:23 +0200461 var matchObj = matchClass.create(match);
462 var tableObj = tableClass.create(matchObj);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000463
464 var table1, table2;
465
Nils Diewald7c8ced22015-04-15 19:21:00 +0000466 it('should fail to load a table async', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200467 expect(tableObj).toBeTruthy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000468
Akron7f9a6a32018-07-18 15:05:23 +0200469 tableObj.getData([], function (tablen) {
Akron671fdb92017-09-12 18:09:46 +0200470 table1 = tablen;
471 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000472 });
473 });
474
Akron671fdb92017-09-12 18:09:46 +0200475
Akronaeeb8252018-09-19 18:51:00 +0200476 xit('should\'nt be parsable (async)', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000477 expect(table1).not.toBeTruthy();
478 });
479
Nils Diewald7c8ced22015-04-15 19:21:00 +0000480
Nils Diewald7c8ced22015-04-15 19:21:00 +0000481 it('should be retrieved async', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200482 expect(tableObj).toBeTruthy();
483 tableObj.getData(undefined, function (x) {
Akron671fdb92017-09-12 18:09:46 +0200484 table = x;
485 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000486 });
487 });
Nils Diewalda297f062015-04-02 00:23:46 +0000488
Akron7f9a6a32018-07-18 15:05:23 +0200489 it('should parse into a table (async)', function () {
490 expect(table).toBeTruthy();
Akron5b1a6af2018-02-05 15:41:16 +0100491
Akron158fce12019-12-17 14:43:29 +0100492 expect(table.length()).toBe(8);
Akron7f9a6a32018-07-18 15:05:23 +0200493
Akron1a780fe2019-05-21 15:59:00 +0200494 expect(table.getToken(0)).toBe("");
495 expect(table.getToken(1)).toBe("Außerdem ");
496 expect(table.getToken(2)).toBe("meist");
497 expect(table.getToken(3)).toBe("deutlich");
Akron158fce12019-12-17 14:43:29 +0100498 expect(table.getToken(5)).toBe("leistungsfähiger");
499 expect(table.getToken(6)).toBe(longString);
Akron7f9a6a32018-07-18 15:05:23 +0200500
Akron1a780fe2019-05-21 15:59:00 +0200501 expect(table.getValue(2, "cnx", "p")[0]).toBe("ADV");
502 expect(table.getValue(2, "cnx", "syn")[0]).toBe("@PREMOD");
503 expect(table.getValue(2, "mate", "l")[0]).toBe("meist");
504 expect(table.getValue(2, "mate", "l")[1]).toBeUndefined();
Akron7f9a6a32018-07-18 15:05:23 +0200505
Akron158fce12019-12-17 14:43:29 +0100506 expect(table.getValue(5, "cnx", "l")[0]).toBe("fähig");
507 expect(table.getValue(5, "cnx", "l")[1]).toBe("leistung");
Akron7f9a6a32018-07-18 15:05:23 +0200508 });
509
510 it('should be rendered async', function () {
Akron5b1a6af2018-02-05 15:41:16 +0100511 var e = table.element().firstChild;
Nils Diewald7c8ced22015-04-15 19:21:00 +0000512 expect(e.nodeName).toBe('TABLE');
513 expect(e.children[0].nodeName).toBe('THEAD');
514 var tr = e.children[0].children[0];
515 expect(tr.nodeName).toBe('TR');
516 expect(tr.children[0].nodeName).toBe('TH');
Nils Diewald58141332015-04-07 16:18:45 +0000517
Nils Diewald7c8ced22015-04-15 19:21:00 +0000518 expect(tr.children[0].firstChild.nodeValue).toBe('Foundry');
519 expect(tr.children[1].firstChild.nodeValue).toBe('Layer');
Akron1a780fe2019-05-21 15:59:00 +0200520
521 expect(tr.children[2].classList.contains('cutted')).toBeTruthy();
522 expect(tr.children[3].firstChild.nodeValue).toBe('Außerdem ');
523
524
525 expect(tr.children[4].firstChild.nodeValue).toBe('meist');
Akronad1e46a2018-09-19 15:55:40 +0200526 expect(tr.children[4].classList.contains('mark')).toBeFalsy();
Akron1a780fe2019-05-21 15:59:00 +0200527 expect(tr.children[5].firstChild.nodeValue).toBe('deutlich');
528 expect(tr.children[5].classList.contains('mark')).toBeTruthy();
Akron158fce12019-12-17 14:43:29 +0100529 expect(tr.children[6].firstChild.nodeValue).toBe('▮');
530 expect(tr.children[7].firstChild.nodeValue).toBe('leistungsfähiger');
531 expect(tr.children[7].classList.contains('mark')).toBeFalsy();
532 expect(tr.children[7].hasAttribute("title")).toBeFalsy();
533 expect(tr.children[8].firstChild.nodeValue).toBe(longString);
534 expect(tr.children[8].getAttribute("title")).toBe(longString);
535 expect(tr.children[9].classList.contains('cutted')).toBeTruthy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000536
537 // first row
538 tr = e.children[1].children[0];
539 expect(tr.nodeName).toBe('TR');
540 expect(tr.getAttribute('tabindex')).toEqual('0');
541 expect(tr.children[0].nodeName).toBe('TH');
542 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
543 expect(tr.children[1].firstChild.nodeValue).toEqual('l');
Akron1a780fe2019-05-21 15:59:00 +0200544 expect(tr.children[4].firstChild.nodeValue).toEqual('meist');
545 expect(tr.children[5].firstChild.nodeValue).toEqual('deutlich');
Akron158fce12019-12-17 14:43:29 +0100546 expect(tr.children[6].firstChild).toBeNull();
547 expect(tr.children[7].firstChild.firstChild.nodeValue).toEqual('fähig');
548 expect(tr.children[7].lastChild.firstChild.nodeValue).toEqual('leistung');
Nils Diewald7c8ced22015-04-15 19:21:00 +0000549
550 // second row
551 tr = e.children[1].children[1];
552 expect(tr.nodeName).toBe('TR');
553 expect(tr.getAttribute('tabindex')).toEqual('0');
554 expect(tr.children[0].nodeName).toBe('TH');
555 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
556 expect(tr.children[1].firstChild.nodeValue).toEqual('p');
Akron1a780fe2019-05-21 15:59:00 +0200557 expect(tr.children[4].firstChild.nodeValue).toEqual('ADV');
558 expect(tr.children[5].firstChild.nodeValue).toEqual('A');
Akron158fce12019-12-17 14:43:29 +0100559 expect(tr.children[6].firstChild).toBeNull();
560 expect(tr.children[7].firstChild.firstChild.nodeValue).toEqual('A');
561 expect(tr.children[7].lastChild.firstChild.nodeValue).toEqual('ADJA');
Akronf2279c42017-12-21 13:48:46 +0100562
Akron158fce12019-12-17 14:43:29 +0100563 expect(tr.children[7].firstChild.getAttribute("title")).toEqual('Adjective');
Akron1a780fe2019-05-21 15:59:00 +0200564 expect(tr.children[4].getAttribute("title")).toEqual('Adverb');
Nils Diewald58141332015-04-07 16:18:45 +0000565 });
Akron7f9a6a32018-07-18 15:05:23 +0200566
567
568 it('should parse into a table view (sync)', function () {
569 var matchElement = matchElementFactory();
570 expect(matchElement.tagName).toEqual('LI');
571
572 // Match
573 expect(matchElement.children[0].tagName).toEqual('DIV');
574
575 // snippet
576 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
577 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
578 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
579
580 // reference
581 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
582 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
583
584 // not yet
585 expect(matchElement.children[0].children[1]).toBe(undefined);
586
587 /*
588 var info = matchClass.create(matchElement).info();
589 info.showTable();
590 */
591 var matchObj = matchClass.create(matchElement);
592 matchObj.open();
593
594 // Match
595 expect(matchElement.children[0].tagName).toEqual('DIV');
596
597 // snippet
598 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
599
600 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
601
602 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
603
604 // reference
605
606 expect(matchElement.children[2].classList.contains('ref')).toBeTruthy();
607 expect(matchElement.children[2].childNodes[1].nodeValue).toEqual('me');
608
609 // Add table
610 matchObj.panel.addTable();
611
612 // now
613 var infotable = matchElement.children[1];
614 expect(infotable.tagName).toEqual('DIV');
615
616 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
617
618 expect(infotable.firstChild.firstChild.firstChild.classList.contains('matchtable')).toBeTruthy();
619
620 // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
621 });
622
Akron158fce12019-12-17 14:43:29 +0100623 it('should parse into a table view with non-verbal elements (sync)', function () {
624 var matchElement = matchElementFactory();
625 expect(matchElement.tagName).toEqual('LI');
626 });
627
Nils Diewald58141332015-04-07 16:18:45 +0000628 });
Nils Diewalda297f062015-04-02 00:23:46 +0000629
Akron7f9a6a32018-07-18 15:05:23 +0200630 describe('KorAP.RelationsView', function () {
Akrond8692de2018-07-26 13:06:01 +0200631 beforeAll(beforeAllFunc);
632 afterAll(afterAllFunc);
633
Nils Diewald7c8ced22015-04-15 19:21:00 +0000634 var tree;
Nils Diewalda297f062015-04-02 00:23:46 +0000635
Nils Diewald7c8ced22015-04-15 19:21:00 +0000636 it('should be rendered async 1', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200637 var matchObj = matchClass.create(match);
638 var relObj = relClass.create(matchObj);
639 expect(relObj).toBeTruthy();
640 relObj.getData(undefined, undefined, "spans", function (y) {
Akron671fdb92017-09-12 18:09:46 +0200641 tree = y;
642 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000643 });
644 });
Nils Diewalda297f062015-04-02 00:23:46 +0000645
Nils Diewald7c8ced22015-04-15 19:21:00 +0000646 it('should be rendered async 2', function () {
Akron7f9a6a32018-07-18 15:05:23 +0200647 expect(tree).toBeTruthy();
648 expect(tree.nodes()).toEqual(49);
649
Nils Diewald7c8ced22015-04-15 19:21:00 +0000650 var e = tree.element();
651 expect(e.nodeName).toEqual('svg');
652 expect(e.getElementsByTagName('g').length).toEqual(48);
Nils Diewald58141332015-04-07 16:18:45 +0000653 });
Akron7f9a6a32018-07-18 15:05:23 +0200654
655
656 it('should add a tree view async 2', function () {
657 var matchElement = matchElementFactory();
658 var matchObj = matchClass.create(matchElement);
659 matchObj.open();
660 matchObj.panel.addTree('mate', 'beebop', 'spans', function () {
661 done();
662 });
663
664 // With added tree
665 var tree = matchElement.children[1].firstChild.firstChild.firstChild;
666 expect(tree.tagName).toEqual('DIV');
667 expect(tree.classList.contains('matchtree')).toBeTruthy();
668 expect(tree.children[0].tagName).toEqual('H6');
669 expect(tree.children[0].children[0].tagName).toEqual('SPAN');
670 expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate');
671 expect(tree.children[0].children[1].tagName).toEqual('SPAN');
672 expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop');
673
674 expect(tree.children[1].tagName).toEqual('DIV');
675 });
676
Akron3bdac532019-03-04 13:24:43 +0100677 it('should make the tree downloadable', function () {
678 var treeClass = matchHierClass.create(treeSnippetHierarchy);
679 var treeElement = treeClass.element();
680 expect(treeElement.tagName).toEqual("svg");
681
682 var base64 = treeClass.toBase64();
683 var str = atob(base64);
684 expect(str).toMatch(new RegExp('<defs><style>path'));
685 expect(str).not.toMatch(new RegExp('&nbsp;'));
686 expect(str).toMatch(new RegExp('&amp;'));
687 });
Nils Diewald58141332015-04-07 16:18:45 +0000688 });
Nils Diewalda297f062015-04-02 00:23:46 +0000689
Nils Diewald7c8ced22015-04-15 19:21:00 +0000690
691 describe('KorAP.MatchTreeItem', function () {
Akrond8692de2018-07-26 13:06:01 +0200692 beforeAll(beforeAllFunc);
693 afterAll(afterAllFunc);
694
Nils Diewald7c8ced22015-04-15 19:21:00 +0000695 it('should be initializable', function () {
696 var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c'])
697 expect(mi.element().firstChild.nodeValue).toEqual('cnx/c');
698 expect(mi.lcField()).toEqual(' cnx/c');
699 expect(mi.foundry()).toEqual('cnx');
700 expect(mi.layer()).toEqual('c');
701 });
Nils Diewalda297f062015-04-02 00:23:46 +0000702 });
Nils Diewalda297f062015-04-02 00:23:46 +0000703
704
Akron671fdb92017-09-12 18:09:46 +0200705 describe('KorAP.MatchRelation', function () {
Akrond8692de2018-07-26 13:06:01 +0200706 beforeAll(beforeAllFunc);
707 afterAll(afterAllFunc);
Akron671fdb92017-09-12 18:09:46 +0200708
709 var relExample = "<span class=\"context-left\"></span>" +
710 "<span class=\"match\">" +
711 " <span xml:id=\"token-GOE/AGA/01784-p199\">" +
712 " <span xlink:title=\"malt/d:ADV\" " +
713 " xlink:type=\"simple\" " +
714 " xlink:href=\"#token-GOE/AGA/01784-p199\">dann</span>" +
715 " </span>" +
716 " zog " +
717 " <span xlink:title=\"malt/d:SUBJ\" " +
718 " xlink:type=\"simple\" " +
719 " xlink:href=\"#token-GOE/AGA/01784-p199\">ich</span>" +
720 " <span xml:id=\"token-GOE/AGA/01784-p202\">" +
721 " <span xlink:title=\"malt/d:OBJA\" " +
722 " xlink:type=\"simple\" " +
723 " xlink:href=\"#token-GOE/AGA/01784-p199\">mich</span>" +
724 " </span>" +
725 "</span>" +
726 "<span class=\"context-right\"></span>";
727
728
729 it('should be initializable', function () {
Akrond8692de2018-07-26 13:06:01 +0200730 var tree = matchRelClass.create();
Akron671fdb92017-09-12 18:09:46 +0200731 expect(tree.size()).toBe(0);
732 });
733
734 it('should be parse string data', function () {
Akrond8692de2018-07-26 13:06:01 +0200735 var tree = matchRelClass.create(relExample);
Akron671fdb92017-09-12 18:09:46 +0200736 expect(tree.size()).toBe(4);
737 });
Akron671fdb92017-09-12 18:09:46 +0200738 });
739
740
Nils Diewald7c8ced22015-04-15 19:21:00 +0000741 describe('KorAP.MatchTreeMenu', function () {
Akrond8692de2018-07-26 13:06:01 +0200742 beforeAll(beforeAllFunc);
743 afterAll(afterAllFunc);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000744
745 it('should be initializable', function () {
Akrond8692de2018-07-26 13:06:01 +0200746 var menu = matchTreeMenuClass.create([
Akron671fdb92017-09-12 18:09:46 +0200747 ['cnx/c', 'cnx', 'c'],
748 ['xip/c', 'xip', 'c']
Akrond8692de2018-07-26 13:06:01 +0200749 ], matchTreeItemClass);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000750
Akrond8692de2018-07-26 13:06:01 +0200751 expect(menu.itemClass()).toEqual(matchTreeItemClass);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000752 expect(menu.element().nodeName).toEqual('UL');
Akronaba7a5a2016-08-15 21:58:33 +0200753 expect(menu.element().classList.contains('visible')).toBeFalsy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000754 expect(menu.limit()).toEqual(6);
755 menu.show();
Akronaba7a5a2016-08-15 21:58:33 +0200756 expect(menu.element().classList.contains('visible')).toBeTruthy();
Akronc1457bf2015-06-11 19:24:00 +0200757 expect(menu.item(0).active()).toBe(false);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000758 });
Nils Diewalda297f062015-04-02 00:23:46 +0000759 });
hebasta999d6c12018-04-23 12:44:59 +0200760
761 //Test display and sorting of meta information
762 describe('KorAP.Meta', function(){
Akrond8692de2018-07-26 13:06:01 +0200763 beforeAll(beforeAllFunc);
764 afterAll(afterAllFunc);
765
766 var met = metaClass.create(match, fields);
hebasta999d6c12018-04-23 12:44:59 +0200767 var mel = met.element();
768
769 // Meta information should be parsed into a list
770 it('should parse in a meta view', function(){
Akronfa32c9d2018-11-20 15:39:18 +0100771 expect(mel.tagName).toEqual('DL');
772 expect(mel.children[0].tagName).toEqual('DIV');
773 expect(mel.children[0].children[0].tagName).toEqual('DT');
774 expect(mel.children[0].children[0].attributes[0].name).toEqual('title');
775 expect(mel.children[0].children[1].tagName).toEqual('DD');
776 expect(mel.children[0].children[1].getAttribute('data-type')).toEqual('type:text')
hebasta999d6c12018-04-23 12:44:59 +0200777
Akronfa32c9d2018-11-20 15:39:18 +0100778 expect(mel.children[0].children[0].firstChild.nodeValue).toEqual('author');
779 expect(mel.children[0].children[1].firstChild.nodeValue).toEqual('Sprachpfleger, u.a.');
780 expect(mel.children[0].children[0].attributes[0].value).toEqual('author');
hebasta999d6c12018-04-23 12:44:59 +0200781 });
782
783
Akronfa32c9d2018-11-20 15:39:18 +0100784 /* The keywords in the meta information list should be formatted to be able
785 to chose each keyword separately in the corpusByMatch assistant. */
786 it('keywords should be formatted', function(){
hebasta999d6c12018-04-23 12:44:59 +0200787
Akronfa32c9d2018-11-20 15:39:18 +0100788 //type:string or type:keyword should b not relevant
789 expect(mel.children[1].children[1].getAttribute('data-type')).toEqual('type:string')
790 expect(mel.children[1].children[1].classList.contains('metakeyvalues')).toBeTruthy;
791 expect(mel.children[1].children[1].children[0].tagName).toEqual('DIV');
792 expect(mel.children[1].children[1].children[0].firstChild.nodeValue).toEqual('corenlp');
793 expect(mel.children[1].children[1].children[1].tagName).toEqual('DIV');
794 expect(mel.children[1].children[1].children[1].firstChild.nodeValue).toEqual('corenlp\/constituency');
795
796 expect(mel.children[2].children[1].classList.contains('metakeyvalues')).toBeTruthy;
797 expect(mel.children[2].children[1].children[0].tagName).toEqual('DIV');
798 expect(mel.children[2].children[1].children[0].firstChild.nodeValue).toEqual('kultur');
799 expect(mel.children[2].children[1].children[1].tagName).toEqual('DIV');
800 expect(mel.children[2].children[1].children[1].firstChild.nodeValue).toEqual('film');
hebasta999d6c12018-04-23 12:44:59 +0200801 });
Akrona0ea3c32018-12-14 18:33:48 +0100802
803 it('attachements should be formatted', function(){
Akrond3bb85b2019-02-08 10:15:13 +0100804 //type:attachement with a link
Akrona0ea3c32018-12-14 18:33:48 +0100805 expect(mel.children[3].children[1].getAttribute('data-type')).toEqual('type:attachement')
806 expect(mel.children[3].children[1].classList.contains('metakeyvalues')).toBeFalsy;
807 expect(mel.children[3].children[0].firstChild.nodeValue).toEqual('xlink');
808 expect(mel.children[3].children[1].firstChild.textContent).toEqual('Cool');
809 expect(mel.children[3].children[1].firstChild.tagName).toEqual('A');
810 expect(mel.children[3].children[1].firstChild.getAttribute('href')).toEqual('https://de.wikipedia.org/wiki/Beispiel');
Akrond3bb85b2019-02-08 10:15:13 +0100811
812 //type:attachement with plain text
813 expect(mel.children[4].children[1].getAttribute('data-type')).toEqual('type:attachement')
814 expect(mel.children[4].children[1].classList.contains('metakeyvalues')).toBeFalsy;
815 expect(mel.children[4].children[0].firstChild.nodeValue).toEqual('z-reference');
816 expect(mel.children[4].children[1].firstChild.nodeValue).toEqual('This is a reference');
817 });
Akrona0ea3c32018-12-14 18:33:48 +0100818
819
hebasta999d6c12018-04-23 12:44:59 +0200820
Akronfa32c9d2018-11-20 15:39:18 +0100821 // Meta information should be sorted alphabetically
822 it('should be alphabetically sorted', function(){
823 var a = mel.children[0].children[0].firstChild.nodeValue;
824 var b = mel.children[1].children[0].firstChild.nodeValue;
825 var c = mel.children[2].children[0].firstChild.nodeValue;
826 expect(a.localeCompare(b)).toBe(-1);
827 expect(b.localeCompare(c)).toBe(-1);
Akrona0ea3c32018-12-14 18:33:48 +0100828 });
829
830
831 it('should handle attachements', function () {
832 let uri = attachementClass.create("data:text/plain;title=new,Hallo");
833 expect(uri.contentType).toEqual("text/plain");
834
835 expect(uri.payload).toEqual("Hallo");
836 expect(uri.base64).toBeFalsy();
837 expect(uri.isLink).toBeFalsy();
838 expect(uri.param["title"]).toEqual("new");
839
840 uri = attachementClass.create("data:application/x.korap-link,https://de.wikipedia.org/wiki/Beispiel");
841 expect(uri.contentType).toEqual("application/x.korap-link");
842 expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel");
843 expect(uri.base64).toBeFalsy();
844 expect(uri.isLink).toBeTruthy();
845 expect(uri.inline().textContent).toEqual("https://de.wikipedia.org/wiki/Beispiel");
846 expect(uri.inline().nodeType).toEqual(1);
847 expect(uri.inline().tagName).toEqual("A");
848 expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer");
849
850
851 uri = attachementClass.create("data:application/x.korap-link;title=Das ist ein Titel,https://de.wikipedia.org/wiki/Beispiel");
852 expect(uri.contentType).toEqual("application/x.korap-link");
853 expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel");
854 expect(uri.base64).toBeFalsy();
855 expect(uri.isLink).toBeTruthy();
856 expect(uri.inline().textContent).toEqual("Das ist ein Titel");
857 expect(uri.inline().nodeType).toEqual(1);
858 expect(uri.inline().tagName).toEqual("A");
859 expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer");
860
861
862 uri = attachementClass.create("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D");
863 expect(uri.contentType).toEqual("text/plain");
864 expect(uri.payload).toEqual("Hello, World!");
865 expect(uri.base64).toBeTruthy();
866 expect(uri.isLink).toBeFalsy();
867 expect(uri.inline().nodeType).toEqual(3);
868 expect(uri.inline().textContent).toEqual("Hello, World!");
869
870 uri = attachementClass.create("data:text/plain;title= new ; subTitle = old ;base64,SGVsbG8sIFdvcmxkIQ%3D%3D");
871 expect(uri.contentType).toEqual("text/plain");
872 expect(uri.payload).toEqual("Hello, World!");
873 expect(uri.param["title"]).toEqual("new");
874 expect(uri.param["subTitle"]).toEqual("old");
875 expect(uri.base64).toBeTruthy();
876 expect(uri.isLink).toBeFalsy();
877 expect(uri.inline().nodeType).toEqual(3);
878 expect(uri.inline().textContent).toEqual("Hello, World!");
879 });
hebasta999d6c12018-04-23 12:44:59 +0200880 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000881 // table = view.toTable();
882 // table.sortBy('');
883 // table.element();
884 // tree = view.toTree();
885 // tree.element();
Nils Diewalda297f062015-04-02 00:23:46 +0000886});