blob: a51fd78d4f3fa686c285d7f956ecaa7cca73ae7a [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>" +
Akrond8692de2018-07-26 13:06:01 +0200132 "<span title=\"cnx/l:fähig\">" +
133 " <span title=\"cnx/l:leistung\">" +
134 " <span title=\"cnx/p:A\">" +
135 " <span title=\"cnx/p:ADJA\">" +
136 " <span title=\"cnx/syn:@NH\">" +
137 " <span title=\"mate/l:leistungsfähig\">" +
138 " <span title=\"mate/m:degree:comp\">" +
139 " <span title=\"mate/p:ADJD\">" +
140 " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" +
141 " </span>" +
142 " </span>" +
143 " </span>" +
144 " </span>" +
145 " </span>" +
146 " </span>" +
147 " </span>" +
Akron5dc31172019-05-15 18:43:48 +0200148 "</span>" +
149 " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können." +
150 "<span class=\"cutted\"><\/span>" +
Akrond8692de2018-07-26 13:06:01 +0200151 "</span>";
152
153 var treeSnippet =
154 "<span class=\"context-left\"></span>" +
155 "<span class=\"match\">" +
156 " <span title=\"xip/c:MC\">" +
157 " <span title=\"xip/c:TOP\">" +
158 " <span title=\"xip/c:PP\">" +
159 " <span title=\"xip/c:PREP\">Mit</span>" +
160 " <span title=\"xip/c:NP\">" +
161 " <span title=\"xip/c:DET\">dieser</span>" +
162 " <span title=\"xip/c:NPA\">" +
163 " <span title=\"xip/c:NOUN\">Methode</span>" +
164 " </span>" +
165 " </span>" +
166 " </span>" +
167 " <span title=\"xip/c:VERB\">ist</span>" +
168 " <mark>" +
169 " <span title=\"xip/c:NP\">" +
170 " <span title=\"xip/c:PRON\">es</span>" +
171 " </span>" +
172 " <span title=\"xip/c:AP\">" +
173 " <span title=\"xip/c:ADV\">nun</span>" +
174 " <span title=\"xip/c:ADJ\">möglich</span>" +
175 " </span>" +
176 " </mark>" +
177 " <span title=\"xip/c:ADV\">z. B.</span>" +
178 " <span title=\"xip/c:NPA\">" +
179 " <span title=\"xip/c:NP\">" +
180 " <span title=\"xip/c:NOUN\">Voice</span>" +
181 " </span>" +
182 " </span>" + "(" +
183 " <span title=\"xip/c:INS\">" +
184 " <span title=\"xip/c:NPA\">" +
185 " <span title=\"xip/c:NP\">" +
186 " <span title=\"xip/c:NOUN\">Sprache</span>" +
187 " </span>" +
188 " </span>" +
189 " </span>" + ")" +
190 " <span title=\"xip/c:VERB\">bevorzugt</span>" +
191 " <span title=\"xip/c:PP\">" +
192 " <span title=\"xip/c:PREP\">in</span>" +
193 " <span title=\"xip/c:NP\">" +
194 " <span title=\"xip/c:PRON\">der</span>" +
195 " </span>" +
196 " <span title=\"xip/c:NPA\">" +
197 " <span title=\"xip/c:NP\">" +
198 " <span title=\"xip/c:NOUN\">Bridge</span>" +
199 " </span>" +
200 " </span>" +
201 " </span>" +
202 " <span title=\"xip/c:INFC\">" +
203 " <span title=\"xip/c:INS\">" +
204 " <span title=\"xip/c:VERB\">weiterzugeben</span>" +
205 " </span>" +
206 " </span>" +
207 " </span>" +
208 " </span>" +
209 "</span>" +
210 "<span class=\"context-right\"></span>";
211
Akron3bdac532019-03-04 13:24:43 +0100212 var treeSnippetHierarchy =
213 "<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 +0200214
Akron3bdac532019-03-04 13:24:43 +0100215 function matchElementFactory () {
Akrond8692de2018-07-26 13:06:01 +0200216 var me = document.createElement('li');
217
218 me.setAttribute(
219 'data-available-info',
220 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' +
221 ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' +
222 ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' +
223 ' tt/p=tokens tt/s=spans');
224
225 me.setAttribute('data-corpus-id', 'WPD');
226 me.setAttribute('data-doc-id', 'FFF');
227 me.setAttribute('data-text-id', '01460');
228 me.setAttribute('data-text-sigle', 'WPD/FFF/01460');
229 me.setAttribute('data-match-id', 'p119-120');
230 me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>';
231 return me;
232 };
233
234 function matchElementReal () {
235 var me = document.createElement('em');
236 me.innerHTML =
237 '<li data-match-id="p85183-85184"' +
238 ' data-text-sigle="GOE/AGI/00000"' +
239 ' 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"' +
240 ' 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;}"' +
241 ' id="GOE/AGI/00000#p85183-85184">' +
242 '<div>' +
243 '<div class="flag"></div>' +
244 '<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>' +
245 '</div>' +
246 '<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>' +
247 '</li>';
248 return me.firstChild;
249 };
250
251 var beforeAllFunc = function () {
252 // Override getMatchInfo API call
253 KorAP.API.getMatchInfo = function (x, param, cb) {
254 if (param['spans'] === undefined || param['spans'] === false)
255 cb({ "snippet": snippet });
256 else
257 cb({ "snippet": treeSnippet });
258 };
259 };
260
261 var afterAllFunc = function () {
262 KorAP.API.getMatchInfo = undefined;
hebasta87f1b1f2019-07-30 13:03:23 +0200263 KorAP.TreeMenu = undefined;
Akrond8692de2018-07-26 13:06:01 +0200264 var body = document.body;
hebasta87f1b1f2019-07-30 13:03:23 +0200265 var i = body.children.length - 1;
266 while (i >= 0) {
Akrond8692de2018-07-26 13:06:01 +0200267 if (body.children[i].nodeType && body.children[i].nodeType === 1) {
268 if (!body.children[i].classList.contains("jasmine_html-reporter")) {
269 body.removeChild(body.children[i]);
270 };
271 };
hebasta87f1b1f2019-07-30 13:03:23 +0200272 i--;
Akrond8692de2018-07-26 13:06:01 +0200273 };
274 };
Akron671fdb92017-09-12 18:09:46 +0200275
Nils Diewald7c8ced22015-04-15 19:21:00 +0000276 describe('KorAP.InfoLayer', function () {
Akrond8692de2018-07-26 13:06:01 +0200277 beforeAll(beforeAllFunc);
278 afterAll(afterAllFunc);
Nils Diewalda297f062015-04-02 00:23:46 +0000279
Nils Diewald7c8ced22015-04-15 19:21:00 +0000280 it('should be initializable', function () {
281 expect(
Akron671fdb92017-09-12 18:09:46 +0200282 function() { infoClass.create() }
Nils Diewald7c8ced22015-04-15 19:21:00 +0000283 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000284
Nils Diewald7c8ced22015-04-15 19:21:00 +0000285 expect(
Akron671fdb92017-09-12 18:09:46 +0200286 function() { infoClass.create("base") }
Nils Diewald7c8ced22015-04-15 19:21:00 +0000287 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000288
Nils Diewald7c8ced22015-04-15 19:21:00 +0000289 var layer = infoClass.create("base", "s");
290 expect(layer).toBeTruthy();
291 expect(layer.foundry).toEqual("base");
292 expect(layer.layer).toEqual("s");
293 expect(layer.type).toEqual("tokens");
Nils Diewalda297f062015-04-02 00:23:46 +0000294
Nils Diewald7c8ced22015-04-15 19:21:00 +0000295 layer = infoClass.create("cnx", "syn", "spans");
296 expect(layer).toBeTruthy();
297 expect(layer.foundry).toEqual("cnx");
298 expect(layer.layer).toEqual("syn");
299 expect(layer.type).toEqual("spans");
Nils Diewald58141332015-04-07 16:18:45 +0000300 });
301 });
Nils Diewalda297f062015-04-02 00:23:46 +0000302
Nils Diewalda297f062015-04-02 00:23:46 +0000303
Nils Diewald7c8ced22015-04-15 19:21:00 +0000304 describe('KorAP.Match', function () {
Akrond8692de2018-07-26 13:06:01 +0200305 beforeAll(beforeAllFunc);
306 afterAll(afterAllFunc);
307
Nils Diewald7c8ced22015-04-15 19:21:00 +0000308 var match = {
309 'corpusID' : 'WPD',
310 'docID' : 'UUU',
311 'textID' : '01912',
312 'matchID' : 'p121-122',
Akron0a6768f2016-07-13 18:00:43 +0200313 'textSigle' : 'WPD/UUU/01912',
Nils Diewald7c8ced22015-04-15 19:21:00 +0000314 'available' : available
315 };
316
Nils Diewald7c8ced22015-04-15 19:21:00 +0000317 it('should be initializable by Object', function () {
318 expect(function() {
Akron671fdb92017-09-12 18:09:46 +0200319 matchClass.create()
Nils Diewald7c8ced22015-04-15 19:21:00 +0000320 }).toThrow(new Error('Missing parameters'));
321
322 expect(matchClass.create(match)).toBeTruthy();
323
324 var m = matchClass.create(match);
Akron0a6768f2016-07-13 18:00:43 +0200325 expect(m.textSigle).toEqual("WPD/UUU/01912");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000326 expect(m.matchID).toEqual("p121-122");
327
328 // /corpus/WPD/UUU.01912/p121-122/matchInfo?spans=false&foundry=*
329 var m = matchClass.create(match);
330
331 // Spans:
332 var spans = m.getSpans();
333 expect(spans[0].foundry).toEqual("base");
334 expect(spans[0].layer).toEqual("s");
335
336 expect(spans[1].foundry).toEqual("corenlp");
337 expect(spans[1].layer).toEqual("c");
338
339 expect(spans[2].foundry).toEqual("corenlp");
340 expect(spans[2].layer).toEqual("s");
341
342 expect(spans[spans.length-1].foundry).toEqual("tt");
343 expect(spans[spans.length-1].layer).toEqual("s");
344
345 // Tokens:
346 var tokens = m.getTokens();
347 expect(tokens[0].foundry).toEqual("corenlp");
348 expect(tokens[0].layer).toEqual("ne");
349
350 expect(tokens[1].foundry).toEqual("corenlp");
351 expect(tokens[1].layer).toEqual("p");
352
353 expect(tokens[tokens.length-1].foundry).toEqual("tt");
354 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewald58141332015-04-07 16:18:45 +0000355 });
Nils Diewalda297f062015-04-02 00:23:46 +0000356
357
Akroncdb0baa2016-11-07 01:52:11 +0100358 it('should be initializable by Node 1', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000359 var m = matchClass.create(matchElementFactory());
Akron0a6768f2016-07-13 18:00:43 +0200360 expect(m.textSigle).toEqual("WPD/FFF/01460");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000361 expect(m.matchID).toEqual("p119-120");
Nils Diewalda297f062015-04-02 00:23:46 +0000362
Nils Diewald7c8ced22015-04-15 19:21:00 +0000363 // Spans:
364 var spans = m.getSpans();
365 expect(spans[0].foundry).toEqual("base");
366 expect(spans[0].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000367
Nils Diewald7c8ced22015-04-15 19:21:00 +0000368 expect(spans[1].foundry).toEqual("corenlp");
369 expect(spans[1].layer).toEqual("c");
Nils Diewalda297f062015-04-02 00:23:46 +0000370
Nils Diewald7c8ced22015-04-15 19:21:00 +0000371 expect(spans[2].foundry).toEqual("corenlp");
372 expect(spans[2].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000373
Nils Diewald7c8ced22015-04-15 19:21:00 +0000374 expect(spans[spans.length-1].foundry).toEqual("tt");
375 expect(spans[spans.length-1].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000376
Nils Diewald7c8ced22015-04-15 19:21:00 +0000377 // Tokens:
378 var tokens = m.getTokens();
379 expect(tokens[0].foundry).toEqual("corenlp");
380 expect(tokens[0].layer).toEqual("ne");
Nils Diewalda297f062015-04-02 00:23:46 +0000381
Nils Diewald7c8ced22015-04-15 19:21:00 +0000382 expect(tokens[1].foundry).toEqual("corenlp");
383 expect(tokens[1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000384
Nils Diewald7c8ced22015-04-15 19:21:00 +0000385 expect(tokens[tokens.length-1].foundry).toEqual("tt");
386 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000387
Nils Diewald7c8ced22015-04-15 19:21:00 +0000388 });
Nils Diewalda297f062015-04-02 00:23:46 +0000389
Akroncdb0baa2016-11-07 01:52:11 +0100390 it('should be initializable by Node 2', function () {
391 var ele = matchElementReal();
392 var m = matchClass.create(ele);
393 expect(m.textSigle).toEqual("GOE/AGI/00000");
394 expect(m.matchID).toEqual("p85183-85184");
395 });
396
397
Nils Diewald7c8ced22015-04-15 19:21:00 +0000398 it('should react to gui actions', function () {
399 var e = matchElementFactory();
Nils Diewalda297f062015-04-02 00:23:46 +0000400
Nils Diewald7c8ced22015-04-15 19:21:00 +0000401 expect(e.classList.contains('active')).toBe(false);
402 expect(e["_match"]).toBe(undefined);
Nils Diewalda297f062015-04-02 00:23:46 +0000403
Nils Diewald7c8ced22015-04-15 19:21:00 +0000404 var m = matchClass.create(e);
405
406 expect(e.classList.contains('active')).toBe(false);
407 expect(e["_match"]).not.toBe(undefined);
hebasta87f1b1f2019-07-30 13:03:23 +0200408
Nils Diewald7c8ced22015-04-15 19:21:00 +0000409 // Open the match
410 m.open();
hebasta87f1b1f2019-07-30 13:03:23 +0200411
Nils Diewald7c8ced22015-04-15 19:21:00 +0000412 expect(e.classList.contains('active')).toBe(true);
413 expect(e["_match"]).not.toBe(undefined);
414
Akronbfe912c2018-07-17 19:30:52 +0200415 actions = e.querySelector("p.ref > div.action.button-group").children;
Akrond141a362018-07-10 18:12:13 +0200416
Akronbfe912c2018-07-17 19:30:52 +0200417 expect(actions[0].getAttribute("class")).toEqual("metatable");
Akronc296ca22018-04-24 16:35:26 +0200418 expect(actions[1].getAttribute("class")).toEqual("info");
419 expect(actions[2].getAttribute("class")).toEqual("tree");
420
Nils Diewald7c8ced22015-04-15 19:21:00 +0000421 // Close the match
Akronec6bb8e2018-08-29 13:07:56 +0200422 m.minimize();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000423 expect(e.classList.contains('active')).toBe(false);
424 expect(e["_match"]).not.toBe(undefined);
Nils Diewald58141332015-04-07 16:18:45 +0000425 });
Nils Diewalda297f062015-04-02 00:23:46 +0000426
Akrond8692de2018-07-26 13:06:01 +0200427 it('should open tree menu', function () {
Akronc296ca22018-04-24 16:35:26 +0200428 var e = matchElementFactory();
429 var m = matchClass.create(e);
430 m.open();
Akronbfe912c2018-07-17 19:30:52 +0200431 var relation = e.querySelector("p.ref > div.action.button-group > span:nth-of-type(3)");
Akronc296ca22018-04-24 16:35:26 +0200432 expect(relation.getAttribute("class")).toEqual("tree");
Akron52ed22d2018-07-11 17:05:19 +0200433 expect(document.getElementsByClassName("button-group-list").length).toEqual(0);
Akronc296ca22018-04-24 16:35:26 +0200434 expect(document.activeElement.tagName).toEqual("BODY");
hebasta87f1b1f2019-07-30 13:03:23 +0200435
Akronc296ca22018-04-24 16:35:26 +0200436 // Show menu
437 relation.click();
Akron52ed22d2018-07-11 17:05:19 +0200438 expect(document.getElementsByClassName("button-group-list").length).toEqual(1);
Akronc296ca22018-04-24 16:35:26 +0200439 expect(document.activeElement.tagName).toEqual("UL");
hebasta87f1b1f2019-07-30 13:03:23 +0200440
Akronc296ca22018-04-24 16:35:26 +0200441 // Choose first tree
Akron52ed22d2018-07-11 17:05:19 +0200442 document.getElementsByClassName("button-group-list")[0].getElementsByTagName("li")[1].click();
Akronc296ca22018-04-24 16:35:26 +0200443 expect(e.querySelector("div.matchinfo div.matchtree h6 span").innerText).toEqual("corenlp");
444
445 // This should blur the focus
446 expect(document.activeElement.tagName).toEqual("BODY");
hebasta87f1b1f2019-07-30 13:03:23 +0200447
Akronc296ca22018-04-24 16:35:26 +0200448 });
449
450 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000451
Akron7f9a6a32018-07-18 15:05:23 +0200452 describe('KorAP.TableView', function () {
Akrond8692de2018-07-26 13:06:01 +0200453 beforeAll(beforeAllFunc);
454 afterAll(afterAllFunc);
Akron5dc31172019-05-15 18:43:48 +0200455
456 let longString = " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können.";
457
Akron7f9a6a32018-07-18 15:05:23 +0200458 var table;
Nils Diewald7c8ced22015-04-15 19:21:00 +0000459
Akron7f9a6a32018-07-18 15:05:23 +0200460 var matchObj = matchClass.create(match);
461 var tableObj = tableClass.create(matchObj);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000462
463 var table1, table2;
464
Nils Diewald7c8ced22015-04-15 19:21:00 +0000465 it('should fail to load a table async', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200466 expect(tableObj).toBeTruthy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000467
Akron7f9a6a32018-07-18 15:05:23 +0200468 tableObj.getData([], function (tablen) {
Akron671fdb92017-09-12 18:09:46 +0200469 table1 = tablen;
470 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000471 });
472 });
473
Akron671fdb92017-09-12 18:09:46 +0200474
Akronaeeb8252018-09-19 18:51:00 +0200475 xit('should\'nt be parsable (async)', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000476 expect(table1).not.toBeTruthy();
477 });
478
Nils Diewald7c8ced22015-04-15 19:21:00 +0000479
Nils Diewald7c8ced22015-04-15 19:21:00 +0000480 it('should be retrieved async', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200481 expect(tableObj).toBeTruthy();
482 tableObj.getData(undefined, function (x) {
Akron671fdb92017-09-12 18:09:46 +0200483 table = x;
484 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000485 });
486 });
Nils Diewalda297f062015-04-02 00:23:46 +0000487
Akron7f9a6a32018-07-18 15:05:23 +0200488 it('should parse into a table (async)', function () {
489 expect(table).toBeTruthy();
Akron5b1a6af2018-02-05 15:41:16 +0100490
Akron1a780fe2019-05-21 15:59:00 +0200491 expect(table.length()).toBe(7);
Akron7f9a6a32018-07-18 15:05:23 +0200492
Akron1a780fe2019-05-21 15:59:00 +0200493 expect(table.getToken(0)).toBe("");
494 expect(table.getToken(1)).toBe("Außerdem ");
495 expect(table.getToken(2)).toBe("meist");
496 expect(table.getToken(3)).toBe("deutlich");
497 expect(table.getToken(4)).toBe("leistungsfähiger");
498 expect(table.getToken(5)).toBe(longString);
Akron7f9a6a32018-07-18 15:05:23 +0200499
Akron1a780fe2019-05-21 15:59:00 +0200500 expect(table.getValue(2, "cnx", "p")[0]).toBe("ADV");
501 expect(table.getValue(2, "cnx", "syn")[0]).toBe("@PREMOD");
502 expect(table.getValue(2, "mate", "l")[0]).toBe("meist");
503 expect(table.getValue(2, "mate", "l")[1]).toBeUndefined();
Akron7f9a6a32018-07-18 15:05:23 +0200504
Akron1a780fe2019-05-21 15:59:00 +0200505 expect(table.getValue(4, "cnx", "l")[0]).toBe("fähig");
506 expect(table.getValue(4, "cnx", "l")[1]).toBe("leistung");
Akron7f9a6a32018-07-18 15:05:23 +0200507 });
508
509 it('should be rendered async', function () {
Akron5b1a6af2018-02-05 15:41:16 +0100510 var e = table.element().firstChild;
Nils Diewald7c8ced22015-04-15 19:21:00 +0000511 expect(e.nodeName).toBe('TABLE');
512 expect(e.children[0].nodeName).toBe('THEAD');
513 var tr = e.children[0].children[0];
514 expect(tr.nodeName).toBe('TR');
515 expect(tr.children[0].nodeName).toBe('TH');
Nils Diewald58141332015-04-07 16:18:45 +0000516
Nils Diewald7c8ced22015-04-15 19:21:00 +0000517 expect(tr.children[0].firstChild.nodeValue).toBe('Foundry');
518 expect(tr.children[1].firstChild.nodeValue).toBe('Layer');
Akron1a780fe2019-05-21 15:59:00 +0200519
520 expect(tr.children[2].classList.contains('cutted')).toBeTruthy();
521 expect(tr.children[3].firstChild.nodeValue).toBe('Außerdem ');
522
523
524 expect(tr.children[4].firstChild.nodeValue).toBe('meist');
Akronad1e46a2018-09-19 15:55:40 +0200525 expect(tr.children[4].classList.contains('mark')).toBeFalsy();
Akron1a780fe2019-05-21 15:59:00 +0200526 expect(tr.children[5].firstChild.nodeValue).toBe('deutlich');
527 expect(tr.children[5].classList.contains('mark')).toBeTruthy();
528 expect(tr.children[6].firstChild.nodeValue).toBe('leistungsfähiger');
529 expect(tr.children[6].classList.contains('mark')).toBeFalsy();
530 expect(tr.children[6].hasAttribute("title")).toBeFalsy();
531 expect(tr.children[7].firstChild.nodeValue).toBe(longString);
532 expect(tr.children[7].getAttribute("title")).toBe(longString);
533 expect(tr.children[8].classList.contains('cutted')).toBeTruthy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000534
535 // first row
536 tr = e.children[1].children[0];
537 expect(tr.nodeName).toBe('TR');
538 expect(tr.getAttribute('tabindex')).toEqual('0');
539 expect(tr.children[0].nodeName).toBe('TH');
540 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
541 expect(tr.children[1].firstChild.nodeValue).toEqual('l');
Akron1a780fe2019-05-21 15:59:00 +0200542 expect(tr.children[4].firstChild.nodeValue).toEqual('meist');
543 expect(tr.children[5].firstChild.nodeValue).toEqual('deutlich');
544 expect(tr.children[6].firstChild.firstChild.nodeValue).toEqual('fähig');
545 expect(tr.children[6].lastChild.firstChild.nodeValue).toEqual('leistung');
Nils Diewald7c8ced22015-04-15 19:21:00 +0000546
547 // second row
548 tr = e.children[1].children[1];
549 expect(tr.nodeName).toBe('TR');
550 expect(tr.getAttribute('tabindex')).toEqual('0');
551 expect(tr.children[0].nodeName).toBe('TH');
552 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
553 expect(tr.children[1].firstChild.nodeValue).toEqual('p');
Akron1a780fe2019-05-21 15:59:00 +0200554 expect(tr.children[4].firstChild.nodeValue).toEqual('ADV');
555 expect(tr.children[5].firstChild.nodeValue).toEqual('A');
556 expect(tr.children[6].firstChild.firstChild.nodeValue).toEqual('A');
557 expect(tr.children[6].lastChild.firstChild.nodeValue).toEqual('ADJA');
Akronf2279c42017-12-21 13:48:46 +0100558
Akron1a780fe2019-05-21 15:59:00 +0200559 expect(tr.children[6].firstChild.getAttribute("title")).toEqual('Adjective');
560 expect(tr.children[4].getAttribute("title")).toEqual('Adverb');
Nils Diewald58141332015-04-07 16:18:45 +0000561 });
Akron7f9a6a32018-07-18 15:05:23 +0200562
563
564 it('should parse into a table view (sync)', function () {
565 var matchElement = matchElementFactory();
566 expect(matchElement.tagName).toEqual('LI');
567
568 // Match
569 expect(matchElement.children[0].tagName).toEqual('DIV');
570
571 // snippet
572 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
573 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
574 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
575
576 // reference
577 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
578 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
579
580 // not yet
581 expect(matchElement.children[0].children[1]).toBe(undefined);
582
583 /*
584 var info = matchClass.create(matchElement).info();
585 info.showTable();
586 */
587 var matchObj = matchClass.create(matchElement);
588 matchObj.open();
589
590 // Match
591 expect(matchElement.children[0].tagName).toEqual('DIV');
592
593 // snippet
594 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
595
596 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
597
598 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
599
600 // reference
601
602 expect(matchElement.children[2].classList.contains('ref')).toBeTruthy();
603 expect(matchElement.children[2].childNodes[1].nodeValue).toEqual('me');
604
605 // Add table
606 matchObj.panel.addTable();
607
608 // now
609 var infotable = matchElement.children[1];
610 expect(infotable.tagName).toEqual('DIV');
611
612 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
613
614 expect(infotable.firstChild.firstChild.firstChild.classList.contains('matchtable')).toBeTruthy();
615
616 // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
617 });
618
Nils Diewald58141332015-04-07 16:18:45 +0000619 });
Nils Diewalda297f062015-04-02 00:23:46 +0000620
Akron7f9a6a32018-07-18 15:05:23 +0200621 describe('KorAP.RelationsView', function () {
Akrond8692de2018-07-26 13:06:01 +0200622 beforeAll(beforeAllFunc);
623 afterAll(afterAllFunc);
624
Nils Diewald7c8ced22015-04-15 19:21:00 +0000625 var tree;
Nils Diewalda297f062015-04-02 00:23:46 +0000626
Nils Diewald7c8ced22015-04-15 19:21:00 +0000627 it('should be rendered async 1', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200628 var matchObj = matchClass.create(match);
629 var relObj = relClass.create(matchObj);
630 expect(relObj).toBeTruthy();
631 relObj.getData(undefined, undefined, "spans", function (y) {
Akron671fdb92017-09-12 18:09:46 +0200632 tree = y;
633 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000634 });
635 });
Nils Diewalda297f062015-04-02 00:23:46 +0000636
Nils Diewald7c8ced22015-04-15 19:21:00 +0000637 it('should be rendered async 2', function () {
Akron7f9a6a32018-07-18 15:05:23 +0200638 expect(tree).toBeTruthy();
639 expect(tree.nodes()).toEqual(49);
640
Nils Diewald7c8ced22015-04-15 19:21:00 +0000641 var e = tree.element();
642 expect(e.nodeName).toEqual('svg');
643 expect(e.getElementsByTagName('g').length).toEqual(48);
Nils Diewald58141332015-04-07 16:18:45 +0000644 });
Akron7f9a6a32018-07-18 15:05:23 +0200645
646
647 it('should add a tree view async 2', function () {
648 var matchElement = matchElementFactory();
649 var matchObj = matchClass.create(matchElement);
650 matchObj.open();
651 matchObj.panel.addTree('mate', 'beebop', 'spans', function () {
652 done();
653 });
654
655 // With added tree
656 var tree = matchElement.children[1].firstChild.firstChild.firstChild;
657 expect(tree.tagName).toEqual('DIV');
658 expect(tree.classList.contains('matchtree')).toBeTruthy();
659 expect(tree.children[0].tagName).toEqual('H6');
660 expect(tree.children[0].children[0].tagName).toEqual('SPAN');
661 expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate');
662 expect(tree.children[0].children[1].tagName).toEqual('SPAN');
663 expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop');
664
665 expect(tree.children[1].tagName).toEqual('DIV');
666 });
667
Akron3bdac532019-03-04 13:24:43 +0100668 it('should make the tree downloadable', function () {
669 var treeClass = matchHierClass.create(treeSnippetHierarchy);
670 var treeElement = treeClass.element();
671 expect(treeElement.tagName).toEqual("svg");
672
673 var base64 = treeClass.toBase64();
674 var str = atob(base64);
675 expect(str).toMatch(new RegExp('<defs><style>path'));
676 expect(str).not.toMatch(new RegExp('&nbsp;'));
677 expect(str).toMatch(new RegExp('&amp;'));
678 });
Nils Diewald58141332015-04-07 16:18:45 +0000679 });
Nils Diewalda297f062015-04-02 00:23:46 +0000680
Nils Diewald7c8ced22015-04-15 19:21:00 +0000681
682 describe('KorAP.MatchTreeItem', function () {
Akrond8692de2018-07-26 13:06:01 +0200683 beforeAll(beforeAllFunc);
684 afterAll(afterAllFunc);
685
Nils Diewald7c8ced22015-04-15 19:21:00 +0000686 it('should be initializable', function () {
687 var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c'])
688 expect(mi.element().firstChild.nodeValue).toEqual('cnx/c');
689 expect(mi.lcField()).toEqual(' cnx/c');
690 expect(mi.foundry()).toEqual('cnx');
691 expect(mi.layer()).toEqual('c');
692 });
Nils Diewalda297f062015-04-02 00:23:46 +0000693 });
Nils Diewalda297f062015-04-02 00:23:46 +0000694
695
Akron671fdb92017-09-12 18:09:46 +0200696 describe('KorAP.MatchRelation', function () {
Akrond8692de2018-07-26 13:06:01 +0200697 beforeAll(beforeAllFunc);
698 afterAll(afterAllFunc);
Akron671fdb92017-09-12 18:09:46 +0200699
700 var relExample = "<span class=\"context-left\"></span>" +
701 "<span class=\"match\">" +
702 " <span xml:id=\"token-GOE/AGA/01784-p199\">" +
703 " <span xlink:title=\"malt/d:ADV\" " +
704 " xlink:type=\"simple\" " +
705 " xlink:href=\"#token-GOE/AGA/01784-p199\">dann</span>" +
706 " </span>" +
707 " zog " +
708 " <span xlink:title=\"malt/d:SUBJ\" " +
709 " xlink:type=\"simple\" " +
710 " xlink:href=\"#token-GOE/AGA/01784-p199\">ich</span>" +
711 " <span xml:id=\"token-GOE/AGA/01784-p202\">" +
712 " <span xlink:title=\"malt/d:OBJA\" " +
713 " xlink:type=\"simple\" " +
714 " xlink:href=\"#token-GOE/AGA/01784-p199\">mich</span>" +
715 " </span>" +
716 "</span>" +
717 "<span class=\"context-right\"></span>";
718
719
720 it('should be initializable', function () {
Akrond8692de2018-07-26 13:06:01 +0200721 var tree = matchRelClass.create();
Akron671fdb92017-09-12 18:09:46 +0200722 expect(tree.size()).toBe(0);
723 });
724
725 it('should be parse string data', function () {
Akrond8692de2018-07-26 13:06:01 +0200726 var tree = matchRelClass.create(relExample);
Akron671fdb92017-09-12 18:09:46 +0200727 expect(tree.size()).toBe(4);
728 });
Akron671fdb92017-09-12 18:09:46 +0200729 });
730
731
Nils Diewald7c8ced22015-04-15 19:21:00 +0000732 describe('KorAP.MatchTreeMenu', function () {
Akrond8692de2018-07-26 13:06:01 +0200733 beforeAll(beforeAllFunc);
734 afterAll(afterAllFunc);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000735
736 it('should be initializable', function () {
Akrond8692de2018-07-26 13:06:01 +0200737 var menu = matchTreeMenuClass.create([
Akron671fdb92017-09-12 18:09:46 +0200738 ['cnx/c', 'cnx', 'c'],
739 ['xip/c', 'xip', 'c']
Akrond8692de2018-07-26 13:06:01 +0200740 ], matchTreeItemClass);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000741
Akrond8692de2018-07-26 13:06:01 +0200742 expect(menu.itemClass()).toEqual(matchTreeItemClass);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000743 expect(menu.element().nodeName).toEqual('UL');
Akronaba7a5a2016-08-15 21:58:33 +0200744 expect(menu.element().classList.contains('visible')).toBeFalsy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000745 expect(menu.limit()).toEqual(6);
746 menu.show();
Akronaba7a5a2016-08-15 21:58:33 +0200747 expect(menu.element().classList.contains('visible')).toBeTruthy();
Akronc1457bf2015-06-11 19:24:00 +0200748 expect(menu.item(0).active()).toBe(false);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000749 });
Nils Diewalda297f062015-04-02 00:23:46 +0000750 });
hebasta999d6c12018-04-23 12:44:59 +0200751
752 //Test display and sorting of meta information
753 describe('KorAP.Meta', function(){
Akrond8692de2018-07-26 13:06:01 +0200754 beforeAll(beforeAllFunc);
755 afterAll(afterAllFunc);
756
757 var met = metaClass.create(match, fields);
hebasta999d6c12018-04-23 12:44:59 +0200758 var mel = met.element();
759
760 // Meta information should be parsed into a list
761 it('should parse in a meta view', function(){
Akronfa32c9d2018-11-20 15:39:18 +0100762 expect(mel.tagName).toEqual('DL');
763 expect(mel.children[0].tagName).toEqual('DIV');
764 expect(mel.children[0].children[0].tagName).toEqual('DT');
765 expect(mel.children[0].children[0].attributes[0].name).toEqual('title');
766 expect(mel.children[0].children[1].tagName).toEqual('DD');
767 expect(mel.children[0].children[1].getAttribute('data-type')).toEqual('type:text')
hebasta999d6c12018-04-23 12:44:59 +0200768
Akronfa32c9d2018-11-20 15:39:18 +0100769 expect(mel.children[0].children[0].firstChild.nodeValue).toEqual('author');
770 expect(mel.children[0].children[1].firstChild.nodeValue).toEqual('Sprachpfleger, u.a.');
771 expect(mel.children[0].children[0].attributes[0].value).toEqual('author');
hebasta999d6c12018-04-23 12:44:59 +0200772 });
773
774
Akronfa32c9d2018-11-20 15:39:18 +0100775 /* The keywords in the meta information list should be formatted to be able
776 to chose each keyword separately in the corpusByMatch assistant. */
777 it('keywords should be formatted', function(){
hebasta999d6c12018-04-23 12:44:59 +0200778
Akronfa32c9d2018-11-20 15:39:18 +0100779 //type:string or type:keyword should b not relevant
780 expect(mel.children[1].children[1].getAttribute('data-type')).toEqual('type:string')
781 expect(mel.children[1].children[1].classList.contains('metakeyvalues')).toBeTruthy;
782 expect(mel.children[1].children[1].children[0].tagName).toEqual('DIV');
783 expect(mel.children[1].children[1].children[0].firstChild.nodeValue).toEqual('corenlp');
784 expect(mel.children[1].children[1].children[1].tagName).toEqual('DIV');
785 expect(mel.children[1].children[1].children[1].firstChild.nodeValue).toEqual('corenlp\/constituency');
786
787 expect(mel.children[2].children[1].classList.contains('metakeyvalues')).toBeTruthy;
788 expect(mel.children[2].children[1].children[0].tagName).toEqual('DIV');
789 expect(mel.children[2].children[1].children[0].firstChild.nodeValue).toEqual('kultur');
790 expect(mel.children[2].children[1].children[1].tagName).toEqual('DIV');
791 expect(mel.children[2].children[1].children[1].firstChild.nodeValue).toEqual('film');
hebasta999d6c12018-04-23 12:44:59 +0200792 });
Akrona0ea3c32018-12-14 18:33:48 +0100793
794 it('attachements should be formatted', function(){
Akrond3bb85b2019-02-08 10:15:13 +0100795 //type:attachement with a link
Akrona0ea3c32018-12-14 18:33:48 +0100796 expect(mel.children[3].children[1].getAttribute('data-type')).toEqual('type:attachement')
797 expect(mel.children[3].children[1].classList.contains('metakeyvalues')).toBeFalsy;
798 expect(mel.children[3].children[0].firstChild.nodeValue).toEqual('xlink');
799 expect(mel.children[3].children[1].firstChild.textContent).toEqual('Cool');
800 expect(mel.children[3].children[1].firstChild.tagName).toEqual('A');
801 expect(mel.children[3].children[1].firstChild.getAttribute('href')).toEqual('https://de.wikipedia.org/wiki/Beispiel');
Akrond3bb85b2019-02-08 10:15:13 +0100802
803 //type:attachement with plain text
804 expect(mel.children[4].children[1].getAttribute('data-type')).toEqual('type:attachement')
805 expect(mel.children[4].children[1].classList.contains('metakeyvalues')).toBeFalsy;
806 expect(mel.children[4].children[0].firstChild.nodeValue).toEqual('z-reference');
807 expect(mel.children[4].children[1].firstChild.nodeValue).toEqual('This is a reference');
808 });
Akrona0ea3c32018-12-14 18:33:48 +0100809
810
hebasta999d6c12018-04-23 12:44:59 +0200811
Akronfa32c9d2018-11-20 15:39:18 +0100812 // Meta information should be sorted alphabetically
813 it('should be alphabetically sorted', function(){
814 var a = mel.children[0].children[0].firstChild.nodeValue;
815 var b = mel.children[1].children[0].firstChild.nodeValue;
816 var c = mel.children[2].children[0].firstChild.nodeValue;
817 expect(a.localeCompare(b)).toBe(-1);
818 expect(b.localeCompare(c)).toBe(-1);
Akrona0ea3c32018-12-14 18:33:48 +0100819 });
820
821
822 it('should handle attachements', function () {
823 let uri = attachementClass.create("data:text/plain;title=new,Hallo");
824 expect(uri.contentType).toEqual("text/plain");
825
826 expect(uri.payload).toEqual("Hallo");
827 expect(uri.base64).toBeFalsy();
828 expect(uri.isLink).toBeFalsy();
829 expect(uri.param["title"]).toEqual("new");
830
831 uri = attachementClass.create("data:application/x.korap-link,https://de.wikipedia.org/wiki/Beispiel");
832 expect(uri.contentType).toEqual("application/x.korap-link");
833 expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel");
834 expect(uri.base64).toBeFalsy();
835 expect(uri.isLink).toBeTruthy();
836 expect(uri.inline().textContent).toEqual("https://de.wikipedia.org/wiki/Beispiel");
837 expect(uri.inline().nodeType).toEqual(1);
838 expect(uri.inline().tagName).toEqual("A");
839 expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer");
840
841
842 uri = attachementClass.create("data:application/x.korap-link;title=Das ist ein Titel,https://de.wikipedia.org/wiki/Beispiel");
843 expect(uri.contentType).toEqual("application/x.korap-link");
844 expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel");
845 expect(uri.base64).toBeFalsy();
846 expect(uri.isLink).toBeTruthy();
847 expect(uri.inline().textContent).toEqual("Das ist ein Titel");
848 expect(uri.inline().nodeType).toEqual(1);
849 expect(uri.inline().tagName).toEqual("A");
850 expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer");
851
852
853 uri = attachementClass.create("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D");
854 expect(uri.contentType).toEqual("text/plain");
855 expect(uri.payload).toEqual("Hello, World!");
856 expect(uri.base64).toBeTruthy();
857 expect(uri.isLink).toBeFalsy();
858 expect(uri.inline().nodeType).toEqual(3);
859 expect(uri.inline().textContent).toEqual("Hello, World!");
860
861 uri = attachementClass.create("data:text/plain;title= new ; subTitle = old ;base64,SGVsbG8sIFdvcmxkIQ%3D%3D");
862 expect(uri.contentType).toEqual("text/plain");
863 expect(uri.payload).toEqual("Hello, World!");
864 expect(uri.param["title"]).toEqual("new");
865 expect(uri.param["subTitle"]).toEqual("old");
866 expect(uri.base64).toBeTruthy();
867 expect(uri.isLink).toBeFalsy();
868 expect(uri.inline().nodeType).toEqual(3);
869 expect(uri.inline().textContent).toEqual("Hello, World!");
870 });
hebasta999d6c12018-04-23 12:44:59 +0200871 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000872 // table = view.toTable();
873 // table.sortBy('');
874 // table.element();
875 // tree = view.toTree();
876 // tree.element();
Nils Diewalda297f062015-04-02 00:23:46 +0000877});