blob: 1a4bd2b5e072b564ea0e11520063624dae306c38 [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\">" +
102 "<span title=\"cnx/l:meist\">" +
Akrond8692de2018-07-26 13:06:01 +0200103 " <span title=\"cnx/p:ADV\">" +
104 " <span title=\"cnx/syn:@PREMOD\">" +
105 " <span title=\"mate/l:meist\">" +
106 " <span title=\"mate/l:meist\">" +
107 " <span title=\"mate/p:ADV\">" +
108 " <span title=\"opennlp/p:ADV\">meist</span>" +
109 " </span>" +
110 " </span>" +
111 " </span>" +
112 " </span>" +
113 " </span>" +
114 "</span>" +
Akronad1e46a2018-09-19 15:55:40 +0200115 "<mark>" +
Akrond8692de2018-07-26 13:06:01 +0200116 "<span title=\"cnx/l:deutlich\">" +
117 " <span title=\"cnx/p:A\">" +
118 " <span title=\"cnx/syn:@PREMOD\">" +
119 " <span title=\"mate/l:deutlich\">" +
120 " <span title=\"mate/m:degree:pos\">" +
121 " <span title=\"mate/p:ADJD\">" +
122 " <span title=\"opennlp/p:ADJD\">deutlich</span>" +
123 " </span>" +
124 " </span>" +
125 " </span>" +
126 " </span>" +
127 " </span>" +
128 "</span>" +
Akronad1e46a2018-09-19 15:55:40 +0200129 "</mark>" +
Akrond8692de2018-07-26 13:06:01 +0200130 "<span title=\"cnx/l:fähig\">" +
131 " <span title=\"cnx/l:leistung\">" +
132 " <span title=\"cnx/p:A\">" +
133 " <span title=\"cnx/p:ADJA\">" +
134 " <span title=\"cnx/syn:@NH\">" +
135 " <span title=\"mate/l:leistungsfähig\">" +
136 " <span title=\"mate/m:degree:comp\">" +
137 " <span title=\"mate/p:ADJD\">" +
138 " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" +
139 " </span>" +
140 " </span>" +
141 " </span>" +
142 " </span>" +
143 " </span>" +
144 " </span>" +
145 " </span>" +
Akron5dc31172019-05-15 18:43:48 +0200146 "</span>" +
147 " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können." +
148 "<span class=\"cutted\"><\/span>" +
Akrond8692de2018-07-26 13:06:01 +0200149 "</span>";
150
151 var treeSnippet =
152 "<span class=\"context-left\"></span>" +
153 "<span class=\"match\">" +
154 " <span title=\"xip/c:MC\">" +
155 " <span title=\"xip/c:TOP\">" +
156 " <span title=\"xip/c:PP\">" +
157 " <span title=\"xip/c:PREP\">Mit</span>" +
158 " <span title=\"xip/c:NP\">" +
159 " <span title=\"xip/c:DET\">dieser</span>" +
160 " <span title=\"xip/c:NPA\">" +
161 " <span title=\"xip/c:NOUN\">Methode</span>" +
162 " </span>" +
163 " </span>" +
164 " </span>" +
165 " <span title=\"xip/c:VERB\">ist</span>" +
166 " <mark>" +
167 " <span title=\"xip/c:NP\">" +
168 " <span title=\"xip/c:PRON\">es</span>" +
169 " </span>" +
170 " <span title=\"xip/c:AP\">" +
171 " <span title=\"xip/c:ADV\">nun</span>" +
172 " <span title=\"xip/c:ADJ\">möglich</span>" +
173 " </span>" +
174 " </mark>" +
175 " <span title=\"xip/c:ADV\">z. B.</span>" +
176 " <span title=\"xip/c:NPA\">" +
177 " <span title=\"xip/c:NP\">" +
178 " <span title=\"xip/c:NOUN\">Voice</span>" +
179 " </span>" +
180 " </span>" + "(" +
181 " <span title=\"xip/c:INS\">" +
182 " <span title=\"xip/c:NPA\">" +
183 " <span title=\"xip/c:NP\">" +
184 " <span title=\"xip/c:NOUN\">Sprache</span>" +
185 " </span>" +
186 " </span>" +
187 " </span>" + ")" +
188 " <span title=\"xip/c:VERB\">bevorzugt</span>" +
189 " <span title=\"xip/c:PP\">" +
190 " <span title=\"xip/c:PREP\">in</span>" +
191 " <span title=\"xip/c:NP\">" +
192 " <span title=\"xip/c:PRON\">der</span>" +
193 " </span>" +
194 " <span title=\"xip/c:NPA\">" +
195 " <span title=\"xip/c:NP\">" +
196 " <span title=\"xip/c:NOUN\">Bridge</span>" +
197 " </span>" +
198 " </span>" +
199 " </span>" +
200 " <span title=\"xip/c:INFC\">" +
201 " <span title=\"xip/c:INS\">" +
202 " <span title=\"xip/c:VERB\">weiterzugeben</span>" +
203 " </span>" +
204 " </span>" +
205 " </span>" +
206 " </span>" +
207 "</span>" +
208 "<span class=\"context-right\"></span>";
209
Akron3bdac532019-03-04 13:24:43 +0100210 var treeSnippetHierarchy =
211 "<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 +0200212
Akron3bdac532019-03-04 13:24:43 +0100213 function matchElementFactory () {
Akrond8692de2018-07-26 13:06:01 +0200214 var me = document.createElement('li');
215
216 me.setAttribute(
217 'data-available-info',
218 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' +
219 ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' +
220 ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' +
221 ' tt/p=tokens tt/s=spans');
222
223 me.setAttribute('data-corpus-id', 'WPD');
224 me.setAttribute('data-doc-id', 'FFF');
225 me.setAttribute('data-text-id', '01460');
226 me.setAttribute('data-text-sigle', 'WPD/FFF/01460');
227 me.setAttribute('data-match-id', 'p119-120');
228 me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>';
229 return me;
230 };
231
232 function matchElementReal () {
233 var me = document.createElement('em');
234 me.innerHTML =
235 '<li data-match-id="p85183-85184"' +
236 ' data-text-sigle="GOE/AGI/00000"' +
237 ' 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"' +
238 ' 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;}"' +
239 ' id="GOE/AGI/00000#p85183-85184">' +
240 '<div>' +
241 '<div class="flag"></div>' +
242 '<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>' +
243 '</div>' +
244 '<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>' +
245 '</li>';
246 return me.firstChild;
247 };
248
249 var beforeAllFunc = function () {
250 // Override getMatchInfo API call
251 KorAP.API.getMatchInfo = function (x, param, cb) {
252 if (param['spans'] === undefined || param['spans'] === false)
253 cb({ "snippet": snippet });
254 else
255 cb({ "snippet": treeSnippet });
256 };
257 };
258
259 var afterAllFunc = function () {
260 KorAP.API.getMatchInfo = undefined;
261 // KorAP.annotationHelper = undefined;
262 var body = document.body;
263 for (var i in body.children) {
264 if (body.children[i].nodeType && body.children[i].nodeType === 1) {
265 if (!body.children[i].classList.contains("jasmine_html-reporter")) {
266 body.removeChild(body.children[i]);
267 };
268 };
269 };
270 };
271
Akron671fdb92017-09-12 18:09:46 +0200272
Nils Diewald7c8ced22015-04-15 19:21:00 +0000273 describe('KorAP.InfoLayer', function () {
Akrond8692de2018-07-26 13:06:01 +0200274 beforeAll(beforeAllFunc);
275 afterAll(afterAllFunc);
Nils Diewalda297f062015-04-02 00:23:46 +0000276
Nils Diewald7c8ced22015-04-15 19:21:00 +0000277 it('should be initializable', function () {
278 expect(
Akron671fdb92017-09-12 18:09:46 +0200279 function() { infoClass.create() }
Nils Diewald7c8ced22015-04-15 19:21:00 +0000280 ).toThrow(new Error("Missing parameters"));
Nils Diewalda297f062015-04-02 00:23:46 +0000281
Nils Diewald7c8ced22015-04-15 19:21:00 +0000282 expect(
Akron671fdb92017-09-12 18:09:46 +0200283 function() { infoClass.create("base") }
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 var layer = infoClass.create("base", "s");
287 expect(layer).toBeTruthy();
288 expect(layer.foundry).toEqual("base");
289 expect(layer.layer).toEqual("s");
290 expect(layer.type).toEqual("tokens");
Nils Diewalda297f062015-04-02 00:23:46 +0000291
Nils Diewald7c8ced22015-04-15 19:21:00 +0000292 layer = infoClass.create("cnx", "syn", "spans");
293 expect(layer).toBeTruthy();
294 expect(layer.foundry).toEqual("cnx");
295 expect(layer.layer).toEqual("syn");
296 expect(layer.type).toEqual("spans");
Nils Diewald58141332015-04-07 16:18:45 +0000297 });
298 });
Nils Diewalda297f062015-04-02 00:23:46 +0000299
Nils Diewalda297f062015-04-02 00:23:46 +0000300
Nils Diewald7c8ced22015-04-15 19:21:00 +0000301 describe('KorAP.Match', function () {
Akrond8692de2018-07-26 13:06:01 +0200302 beforeAll(beforeAllFunc);
303 afterAll(afterAllFunc);
304
Nils Diewald7c8ced22015-04-15 19:21:00 +0000305 var match = {
306 'corpusID' : 'WPD',
307 'docID' : 'UUU',
308 'textID' : '01912',
309 'matchID' : 'p121-122',
Akron0a6768f2016-07-13 18:00:43 +0200310 'textSigle' : 'WPD/UUU/01912',
Nils Diewald7c8ced22015-04-15 19:21:00 +0000311 'available' : available
312 };
313
Nils Diewald7c8ced22015-04-15 19:21:00 +0000314 it('should be initializable by Object', function () {
315 expect(function() {
Akron671fdb92017-09-12 18:09:46 +0200316 matchClass.create()
Nils Diewald7c8ced22015-04-15 19:21:00 +0000317 }).toThrow(new Error('Missing parameters'));
318
319 expect(matchClass.create(match)).toBeTruthy();
320
321 var m = matchClass.create(match);
Akron0a6768f2016-07-13 18:00:43 +0200322 expect(m.textSigle).toEqual("WPD/UUU/01912");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000323 expect(m.matchID).toEqual("p121-122");
324
325 // /corpus/WPD/UUU.01912/p121-122/matchInfo?spans=false&foundry=*
326 var m = matchClass.create(match);
327
328 // Spans:
329 var spans = m.getSpans();
330 expect(spans[0].foundry).toEqual("base");
331 expect(spans[0].layer).toEqual("s");
332
333 expect(spans[1].foundry).toEqual("corenlp");
334 expect(spans[1].layer).toEqual("c");
335
336 expect(spans[2].foundry).toEqual("corenlp");
337 expect(spans[2].layer).toEqual("s");
338
339 expect(spans[spans.length-1].foundry).toEqual("tt");
340 expect(spans[spans.length-1].layer).toEqual("s");
341
342 // Tokens:
343 var tokens = m.getTokens();
344 expect(tokens[0].foundry).toEqual("corenlp");
345 expect(tokens[0].layer).toEqual("ne");
346
347 expect(tokens[1].foundry).toEqual("corenlp");
348 expect(tokens[1].layer).toEqual("p");
349
350 expect(tokens[tokens.length-1].foundry).toEqual("tt");
351 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewald58141332015-04-07 16:18:45 +0000352 });
Nils Diewalda297f062015-04-02 00:23:46 +0000353
354
Akroncdb0baa2016-11-07 01:52:11 +0100355 it('should be initializable by Node 1', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000356 var m = matchClass.create(matchElementFactory());
Akron0a6768f2016-07-13 18:00:43 +0200357 expect(m.textSigle).toEqual("WPD/FFF/01460");
Nils Diewald7c8ced22015-04-15 19:21:00 +0000358 expect(m.matchID).toEqual("p119-120");
Nils Diewalda297f062015-04-02 00:23:46 +0000359
Nils Diewald7c8ced22015-04-15 19:21:00 +0000360 // Spans:
361 var spans = m.getSpans();
362 expect(spans[0].foundry).toEqual("base");
363 expect(spans[0].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000364
Nils Diewald7c8ced22015-04-15 19:21:00 +0000365 expect(spans[1].foundry).toEqual("corenlp");
366 expect(spans[1].layer).toEqual("c");
Nils Diewalda297f062015-04-02 00:23:46 +0000367
Nils Diewald7c8ced22015-04-15 19:21:00 +0000368 expect(spans[2].foundry).toEqual("corenlp");
369 expect(spans[2].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000370
Nils Diewald7c8ced22015-04-15 19:21:00 +0000371 expect(spans[spans.length-1].foundry).toEqual("tt");
372 expect(spans[spans.length-1].layer).toEqual("s");
Nils Diewalda297f062015-04-02 00:23:46 +0000373
Nils Diewald7c8ced22015-04-15 19:21:00 +0000374 // Tokens:
375 var tokens = m.getTokens();
376 expect(tokens[0].foundry).toEqual("corenlp");
377 expect(tokens[0].layer).toEqual("ne");
Nils Diewalda297f062015-04-02 00:23:46 +0000378
Nils Diewald7c8ced22015-04-15 19:21:00 +0000379 expect(tokens[1].foundry).toEqual("corenlp");
380 expect(tokens[1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000381
Nils Diewald7c8ced22015-04-15 19:21:00 +0000382 expect(tokens[tokens.length-1].foundry).toEqual("tt");
383 expect(tokens[tokens.length-1].layer).toEqual("p");
Nils Diewalda297f062015-04-02 00:23:46 +0000384
Nils Diewald7c8ced22015-04-15 19:21:00 +0000385 });
Nils Diewalda297f062015-04-02 00:23:46 +0000386
Akroncdb0baa2016-11-07 01:52:11 +0100387 it('should be initializable by Node 2', function () {
388 var ele = matchElementReal();
389 var m = matchClass.create(ele);
390 expect(m.textSigle).toEqual("GOE/AGI/00000");
391 expect(m.matchID).toEqual("p85183-85184");
392 });
393
394
Nils Diewald7c8ced22015-04-15 19:21:00 +0000395 it('should react to gui actions', function () {
396 var e = matchElementFactory();
Nils Diewalda297f062015-04-02 00:23:46 +0000397
Nils Diewald7c8ced22015-04-15 19:21:00 +0000398 expect(e.classList.contains('active')).toBe(false);
399 expect(e["_match"]).toBe(undefined);
Nils Diewalda297f062015-04-02 00:23:46 +0000400
Nils Diewald7c8ced22015-04-15 19:21:00 +0000401 var m = matchClass.create(e);
402
403 expect(e.classList.contains('active')).toBe(false);
404 expect(e["_match"]).not.toBe(undefined);
405
406 // Open the match
407 m.open();
408
409 expect(e.classList.contains('active')).toBe(true);
410 expect(e["_match"]).not.toBe(undefined);
411
Akronbfe912c2018-07-17 19:30:52 +0200412 actions = e.querySelector("p.ref > div.action.button-group").children;
Akrond141a362018-07-10 18:12:13 +0200413
Akronbfe912c2018-07-17 19:30:52 +0200414 expect(actions[0].getAttribute("class")).toEqual("metatable");
Akronc296ca22018-04-24 16:35:26 +0200415 expect(actions[1].getAttribute("class")).toEqual("info");
416 expect(actions[2].getAttribute("class")).toEqual("tree");
417
Nils Diewald7c8ced22015-04-15 19:21:00 +0000418 // Close the match
Akronec6bb8e2018-08-29 13:07:56 +0200419 m.minimize();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000420 expect(e.classList.contains('active')).toBe(false);
421 expect(e["_match"]).not.toBe(undefined);
Nils Diewald58141332015-04-07 16:18:45 +0000422 });
Nils Diewalda297f062015-04-02 00:23:46 +0000423
Akrond8692de2018-07-26 13:06:01 +0200424 it('should open tree menu', function () {
Akronc296ca22018-04-24 16:35:26 +0200425 var e = matchElementFactory();
426 var m = matchClass.create(e);
427 m.open();
Akronbfe912c2018-07-17 19:30:52 +0200428 var relation = e.querySelector("p.ref > div.action.button-group > span:nth-of-type(3)");
Akronc296ca22018-04-24 16:35:26 +0200429 expect(relation.getAttribute("class")).toEqual("tree");
Akron52ed22d2018-07-11 17:05:19 +0200430 expect(document.getElementsByClassName("button-group-list").length).toEqual(0);
Akronc296ca22018-04-24 16:35:26 +0200431
432 expect(document.activeElement.tagName).toEqual("BODY");
433
434 // Show menu
435 relation.click();
Akron52ed22d2018-07-11 17:05:19 +0200436 expect(document.getElementsByClassName("button-group-list").length).toEqual(1);
Akronc296ca22018-04-24 16:35:26 +0200437
438 expect(document.activeElement.tagName).toEqual("UL");
439
440 // Choose first tree
Akron52ed22d2018-07-11 17:05:19 +0200441 document.getElementsByClassName("button-group-list")[0].getElementsByTagName("li")[1].click();
Akronc296ca22018-04-24 16:35:26 +0200442 expect(e.querySelector("div.matchinfo div.matchtree h6 span").innerText).toEqual("corenlp");
443
444 // This should blur the focus
445 expect(document.activeElement.tagName).toEqual("BODY");
446 });
447
448 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000449
Akron7f9a6a32018-07-18 15:05:23 +0200450 describe('KorAP.TableView', function () {
Akrond8692de2018-07-26 13:06:01 +0200451 beforeAll(beforeAllFunc);
452 afterAll(afterAllFunc);
Akron5dc31172019-05-15 18:43:48 +0200453
454 let longString = " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können.";
455
Akron7f9a6a32018-07-18 15:05:23 +0200456 var table;
Nils Diewald7c8ced22015-04-15 19:21:00 +0000457
Akron7f9a6a32018-07-18 15:05:23 +0200458 var matchObj = matchClass.create(match);
459 var tableObj = tableClass.create(matchObj);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000460
461 var table1, table2;
462
Nils Diewald7c8ced22015-04-15 19:21:00 +0000463 it('should fail to load a table async', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200464 expect(tableObj).toBeTruthy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000465
Akron7f9a6a32018-07-18 15:05:23 +0200466 tableObj.getData([], function (tablen) {
Akron671fdb92017-09-12 18:09:46 +0200467 table1 = tablen;
468 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000469 });
470 });
471
Akron671fdb92017-09-12 18:09:46 +0200472
Akronaeeb8252018-09-19 18:51:00 +0200473 xit('should\'nt be parsable (async)', function () {
Nils Diewald7c8ced22015-04-15 19:21:00 +0000474 expect(table1).not.toBeTruthy();
475 });
476
Nils Diewald7c8ced22015-04-15 19:21:00 +0000477
Nils Diewald7c8ced22015-04-15 19:21:00 +0000478 it('should be retrieved async', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200479 expect(tableObj).toBeTruthy();
480 tableObj.getData(undefined, function (x) {
Akron671fdb92017-09-12 18:09:46 +0200481 table = x;
482 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000483 });
484 });
Nils Diewalda297f062015-04-02 00:23:46 +0000485
Akron7f9a6a32018-07-18 15:05:23 +0200486 it('should parse into a table (async)', function () {
487 expect(table).toBeTruthy();
Akron5b1a6af2018-02-05 15:41:16 +0100488
Akron083ec572019-05-16 18:30:40 +0200489 expect(table.length()).toBe(5);
Akron7f9a6a32018-07-18 15:05:23 +0200490
491 expect(table.getToken(0)).toBe("meist");
492 expect(table.getToken(1)).toBe("deutlich");
493 expect(table.getToken(2)).toBe("leistungsfähiger");
Akron5dc31172019-05-15 18:43:48 +0200494 expect(table.getToken(3)).toBe(longString);
Akron7f9a6a32018-07-18 15:05:23 +0200495
496 expect(table.getValue(0, "cnx", "p")[0]).toBe("ADV");
497 expect(table.getValue(0, "cnx", "syn")[0]).toBe("@PREMOD");
498 expect(table.getValue(0, "mate", "l")[0]).toBe("meist");
499 expect(table.getValue(0, "mate", "l")[1]).toBeUndefined();
500
501 expect(table.getValue(2, "cnx", "l")[0]).toBe("fähig");
502 expect(table.getValue(2, "cnx", "l")[1]).toBe("leistung");
503 });
504
505 it('should be rendered async', function () {
Akron5b1a6af2018-02-05 15:41:16 +0100506 var e = table.element().firstChild;
Nils Diewald7c8ced22015-04-15 19:21:00 +0000507 expect(e.nodeName).toBe('TABLE');
508 expect(e.children[0].nodeName).toBe('THEAD');
509 var tr = e.children[0].children[0];
510 expect(tr.nodeName).toBe('TR');
511 expect(tr.children[0].nodeName).toBe('TH');
Nils Diewald58141332015-04-07 16:18:45 +0000512
Nils Diewald7c8ced22015-04-15 19:21:00 +0000513 expect(tr.children[0].firstChild.nodeValue).toBe('Foundry');
514 expect(tr.children[1].firstChild.nodeValue).toBe('Layer');
515 expect(tr.children[2].firstChild.nodeValue).toBe('meist');
Akronad1e46a2018-09-19 15:55:40 +0200516 expect(tr.children[2].classList.contains('mark')).toBeFalsy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000517 expect(tr.children[3].firstChild.nodeValue).toBe('deutlich');
Akronad1e46a2018-09-19 15:55:40 +0200518 expect(tr.children[3].classList.contains('mark')).toBeTruthy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000519 expect(tr.children[4].firstChild.nodeValue).toBe('leistungsfähiger');
Akronad1e46a2018-09-19 15:55:40 +0200520 expect(tr.children[4].classList.contains('mark')).toBeFalsy();
Akron083ec572019-05-16 18:30:40 +0200521 expect(tr.children[4].hasAttribute("title")).toBeFalsy();
Akron5dc31172019-05-15 18:43:48 +0200522 expect(tr.children[5].firstChild.nodeValue).toBe(longString);
523 expect(tr.children[5].getAttribute("title")).toBe(longString);
Akron083ec572019-05-16 18:30:40 +0200524 expect(tr.children[6].classList.contains('cutted')).toBeTruthy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000525
526 // first row
527 tr = e.children[1].children[0];
528 expect(tr.nodeName).toBe('TR');
529 expect(tr.getAttribute('tabindex')).toEqual('0');
530 expect(tr.children[0].nodeName).toBe('TH');
531 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
532 expect(tr.children[1].firstChild.nodeValue).toEqual('l');
533 expect(tr.children[2].firstChild.nodeValue).toEqual('meist');
534 expect(tr.children[3].firstChild.nodeValue).toEqual('deutlich');
Akron47774c42017-07-03 20:14:55 +0200535 expect(tr.children[4].firstChild.firstChild.nodeValue).toEqual('fähig');
536 expect(tr.children[4].lastChild.firstChild.nodeValue).toEqual('leistung');
Nils Diewald7c8ced22015-04-15 19:21:00 +0000537
538 // second row
539 tr = e.children[1].children[1];
540 expect(tr.nodeName).toBe('TR');
541 expect(tr.getAttribute('tabindex')).toEqual('0');
542 expect(tr.children[0].nodeName).toBe('TH');
543 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
544 expect(tr.children[1].firstChild.nodeValue).toEqual('p');
545 expect(tr.children[2].firstChild.nodeValue).toEqual('ADV');
546 expect(tr.children[3].firstChild.nodeValue).toEqual('A');
Akron47774c42017-07-03 20:14:55 +0200547 expect(tr.children[4].firstChild.firstChild.nodeValue).toEqual('A');
548 expect(tr.children[4].lastChild.firstChild.nodeValue).toEqual('ADJA');
Akronf2279c42017-12-21 13:48:46 +0100549
550 expect(tr.children[4].firstChild.getAttribute("title")).toEqual('Adjective');
551 expect(tr.children[2].getAttribute("title")).toEqual('Adverb');
552
Nils Diewald58141332015-04-07 16:18:45 +0000553 });
Akron7f9a6a32018-07-18 15:05:23 +0200554
555
556 it('should parse into a table view (sync)', function () {
557 var matchElement = matchElementFactory();
558 expect(matchElement.tagName).toEqual('LI');
559
560 // Match
561 expect(matchElement.children[0].tagName).toEqual('DIV');
562
563 // snippet
564 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
565 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
566 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
567
568 // reference
569 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
570 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
571
572 // not yet
573 expect(matchElement.children[0].children[1]).toBe(undefined);
574
575 /*
576 var info = matchClass.create(matchElement).info();
577 info.showTable();
578 */
579 var matchObj = matchClass.create(matchElement);
580 matchObj.open();
581
582 // Match
583 expect(matchElement.children[0].tagName).toEqual('DIV');
584
585 // snippet
586 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
587
588 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
589
590 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
591
592 // reference
593
594 expect(matchElement.children[2].classList.contains('ref')).toBeTruthy();
595 expect(matchElement.children[2].childNodes[1].nodeValue).toEqual('me');
596
597 // Add table
598 matchObj.panel.addTable();
599
600 // now
601 var infotable = matchElement.children[1];
602 expect(infotable.tagName).toEqual('DIV');
603
604 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
605
606 expect(infotable.firstChild.firstChild.firstChild.classList.contains('matchtable')).toBeTruthy();
607
608 // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
609 });
610
Nils Diewald58141332015-04-07 16:18:45 +0000611 });
Nils Diewalda297f062015-04-02 00:23:46 +0000612
Akron7f9a6a32018-07-18 15:05:23 +0200613 describe('KorAP.RelationsView', function () {
Akrond8692de2018-07-26 13:06:01 +0200614 beforeAll(beforeAllFunc);
615 afterAll(afterAllFunc);
616
Nils Diewald7c8ced22015-04-15 19:21:00 +0000617 var tree;
Nils Diewalda297f062015-04-02 00:23:46 +0000618
Nils Diewald7c8ced22015-04-15 19:21:00 +0000619 it('should be rendered async 1', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200620 var matchObj = matchClass.create(match);
621 var relObj = relClass.create(matchObj);
622 expect(relObj).toBeTruthy();
623 relObj.getData(undefined, undefined, "spans", function (y) {
Akron671fdb92017-09-12 18:09:46 +0200624 tree = y;
625 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000626 });
627 });
Nils Diewalda297f062015-04-02 00:23:46 +0000628
Nils Diewald7c8ced22015-04-15 19:21:00 +0000629 it('should be rendered async 2', function () {
Akron7f9a6a32018-07-18 15:05:23 +0200630 expect(tree).toBeTruthy();
631 expect(tree.nodes()).toEqual(49);
632
Nils Diewald7c8ced22015-04-15 19:21:00 +0000633 var e = tree.element();
634 expect(e.nodeName).toEqual('svg');
635 expect(e.getElementsByTagName('g').length).toEqual(48);
Nils Diewald58141332015-04-07 16:18:45 +0000636 });
Akron7f9a6a32018-07-18 15:05:23 +0200637
638
639 it('should add a tree view async 2', function () {
640 var matchElement = matchElementFactory();
641 var matchObj = matchClass.create(matchElement);
642 matchObj.open();
643 matchObj.panel.addTree('mate', 'beebop', 'spans', function () {
644 done();
645 });
646
647 // With added tree
648 var tree = matchElement.children[1].firstChild.firstChild.firstChild;
649 expect(tree.tagName).toEqual('DIV');
650 expect(tree.classList.contains('matchtree')).toBeTruthy();
651 expect(tree.children[0].tagName).toEqual('H6');
652 expect(tree.children[0].children[0].tagName).toEqual('SPAN');
653 expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate');
654 expect(tree.children[0].children[1].tagName).toEqual('SPAN');
655 expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop');
656
657 expect(tree.children[1].tagName).toEqual('DIV');
658 });
659
Akron3bdac532019-03-04 13:24:43 +0100660 it('should make the tree downloadable', function () {
661 var treeClass = matchHierClass.create(treeSnippetHierarchy);
662 var treeElement = treeClass.element();
663 expect(treeElement.tagName).toEqual("svg");
664
665 var base64 = treeClass.toBase64();
666 var str = atob(base64);
667 expect(str).toMatch(new RegExp('<defs><style>path'));
668 expect(str).not.toMatch(new RegExp('&nbsp;'));
669 expect(str).toMatch(new RegExp('&amp;'));
670 });
Nils Diewald58141332015-04-07 16:18:45 +0000671 });
Nils Diewalda297f062015-04-02 00:23:46 +0000672
Nils Diewald7c8ced22015-04-15 19:21:00 +0000673
674 describe('KorAP.MatchTreeItem', function () {
Akrond8692de2018-07-26 13:06:01 +0200675 beforeAll(beforeAllFunc);
676 afterAll(afterAllFunc);
677
Nils Diewald7c8ced22015-04-15 19:21:00 +0000678 it('should be initializable', function () {
679 var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c'])
680 expect(mi.element().firstChild.nodeValue).toEqual('cnx/c');
681 expect(mi.lcField()).toEqual(' cnx/c');
682 expect(mi.foundry()).toEqual('cnx');
683 expect(mi.layer()).toEqual('c');
684 });
Nils Diewalda297f062015-04-02 00:23:46 +0000685 });
Nils Diewalda297f062015-04-02 00:23:46 +0000686
687
Akron671fdb92017-09-12 18:09:46 +0200688 describe('KorAP.MatchRelation', function () {
Akrond8692de2018-07-26 13:06:01 +0200689 beforeAll(beforeAllFunc);
690 afterAll(afterAllFunc);
Akron671fdb92017-09-12 18:09:46 +0200691
692 var relExample = "<span class=\"context-left\"></span>" +
693 "<span class=\"match\">" +
694 " <span xml:id=\"token-GOE/AGA/01784-p199\">" +
695 " <span xlink:title=\"malt/d:ADV\" " +
696 " xlink:type=\"simple\" " +
697 " xlink:href=\"#token-GOE/AGA/01784-p199\">dann</span>" +
698 " </span>" +
699 " zog " +
700 " <span xlink:title=\"malt/d:SUBJ\" " +
701 " xlink:type=\"simple\" " +
702 " xlink:href=\"#token-GOE/AGA/01784-p199\">ich</span>" +
703 " <span xml:id=\"token-GOE/AGA/01784-p202\">" +
704 " <span xlink:title=\"malt/d:OBJA\" " +
705 " xlink:type=\"simple\" " +
706 " xlink:href=\"#token-GOE/AGA/01784-p199\">mich</span>" +
707 " </span>" +
708 "</span>" +
709 "<span class=\"context-right\"></span>";
710
711
712 it('should be initializable', function () {
Akrond8692de2018-07-26 13:06:01 +0200713 var tree = matchRelClass.create();
Akron671fdb92017-09-12 18:09:46 +0200714 expect(tree.size()).toBe(0);
715 });
716
717 it('should be parse string data', function () {
Akrond8692de2018-07-26 13:06:01 +0200718 var tree = matchRelClass.create(relExample);
Akron671fdb92017-09-12 18:09:46 +0200719 expect(tree.size()).toBe(4);
720 });
Akron671fdb92017-09-12 18:09:46 +0200721 });
722
723
Nils Diewald7c8ced22015-04-15 19:21:00 +0000724 describe('KorAP.MatchTreeMenu', function () {
Akrond8692de2018-07-26 13:06:01 +0200725 beforeAll(beforeAllFunc);
726 afterAll(afterAllFunc);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000727
728 it('should be initializable', function () {
Akrond8692de2018-07-26 13:06:01 +0200729 var menu = matchTreeMenuClass.create([
Akron671fdb92017-09-12 18:09:46 +0200730 ['cnx/c', 'cnx', 'c'],
731 ['xip/c', 'xip', 'c']
Akrond8692de2018-07-26 13:06:01 +0200732 ], matchTreeItemClass);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000733
Akrond8692de2018-07-26 13:06:01 +0200734 expect(menu.itemClass()).toEqual(matchTreeItemClass);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000735 expect(menu.element().nodeName).toEqual('UL');
Akronaba7a5a2016-08-15 21:58:33 +0200736 expect(menu.element().classList.contains('visible')).toBeFalsy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000737 expect(menu.limit()).toEqual(6);
738 menu.show();
Akronaba7a5a2016-08-15 21:58:33 +0200739 expect(menu.element().classList.contains('visible')).toBeTruthy();
Akronc1457bf2015-06-11 19:24:00 +0200740 expect(menu.item(0).active()).toBe(false);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000741 });
Nils Diewalda297f062015-04-02 00:23:46 +0000742 });
hebasta999d6c12018-04-23 12:44:59 +0200743
744 //Test display and sorting of meta information
745 describe('KorAP.Meta', function(){
Akrond8692de2018-07-26 13:06:01 +0200746 beforeAll(beforeAllFunc);
747 afterAll(afterAllFunc);
748
749 var met = metaClass.create(match, fields);
hebasta999d6c12018-04-23 12:44:59 +0200750 var mel = met.element();
751
752 // Meta information should be parsed into a list
753 it('should parse in a meta view', function(){
Akronfa32c9d2018-11-20 15:39:18 +0100754 expect(mel.tagName).toEqual('DL');
755 expect(mel.children[0].tagName).toEqual('DIV');
756 expect(mel.children[0].children[0].tagName).toEqual('DT');
757 expect(mel.children[0].children[0].attributes[0].name).toEqual('title');
758 expect(mel.children[0].children[1].tagName).toEqual('DD');
759 expect(mel.children[0].children[1].getAttribute('data-type')).toEqual('type:text')
hebasta999d6c12018-04-23 12:44:59 +0200760
Akronfa32c9d2018-11-20 15:39:18 +0100761 expect(mel.children[0].children[0].firstChild.nodeValue).toEqual('author');
762 expect(mel.children[0].children[1].firstChild.nodeValue).toEqual('Sprachpfleger, u.a.');
763 expect(mel.children[0].children[0].attributes[0].value).toEqual('author');
hebasta999d6c12018-04-23 12:44:59 +0200764 });
765
766
Akronfa32c9d2018-11-20 15:39:18 +0100767 /* The keywords in the meta information list should be formatted to be able
768 to chose each keyword separately in the corpusByMatch assistant. */
769 it('keywords should be formatted', function(){
hebasta999d6c12018-04-23 12:44:59 +0200770
Akronfa32c9d2018-11-20 15:39:18 +0100771 //type:string or type:keyword should b not relevant
772 expect(mel.children[1].children[1].getAttribute('data-type')).toEqual('type:string')
773 expect(mel.children[1].children[1].classList.contains('metakeyvalues')).toBeTruthy;
774 expect(mel.children[1].children[1].children[0].tagName).toEqual('DIV');
775 expect(mel.children[1].children[1].children[0].firstChild.nodeValue).toEqual('corenlp');
776 expect(mel.children[1].children[1].children[1].tagName).toEqual('DIV');
777 expect(mel.children[1].children[1].children[1].firstChild.nodeValue).toEqual('corenlp\/constituency');
778
779 expect(mel.children[2].children[1].classList.contains('metakeyvalues')).toBeTruthy;
780 expect(mel.children[2].children[1].children[0].tagName).toEqual('DIV');
781 expect(mel.children[2].children[1].children[0].firstChild.nodeValue).toEqual('kultur');
782 expect(mel.children[2].children[1].children[1].tagName).toEqual('DIV');
783 expect(mel.children[2].children[1].children[1].firstChild.nodeValue).toEqual('film');
hebasta999d6c12018-04-23 12:44:59 +0200784 });
Akrona0ea3c32018-12-14 18:33:48 +0100785
786 it('attachements should be formatted', function(){
Akrond3bb85b2019-02-08 10:15:13 +0100787 //type:attachement with a link
Akrona0ea3c32018-12-14 18:33:48 +0100788 expect(mel.children[3].children[1].getAttribute('data-type')).toEqual('type:attachement')
789 expect(mel.children[3].children[1].classList.contains('metakeyvalues')).toBeFalsy;
790 expect(mel.children[3].children[0].firstChild.nodeValue).toEqual('xlink');
791 expect(mel.children[3].children[1].firstChild.textContent).toEqual('Cool');
792 expect(mel.children[3].children[1].firstChild.tagName).toEqual('A');
793 expect(mel.children[3].children[1].firstChild.getAttribute('href')).toEqual('https://de.wikipedia.org/wiki/Beispiel');
Akrond3bb85b2019-02-08 10:15:13 +0100794
795 //type:attachement with plain text
796 expect(mel.children[4].children[1].getAttribute('data-type')).toEqual('type:attachement')
797 expect(mel.children[4].children[1].classList.contains('metakeyvalues')).toBeFalsy;
798 expect(mel.children[4].children[0].firstChild.nodeValue).toEqual('z-reference');
799 expect(mel.children[4].children[1].firstChild.nodeValue).toEqual('This is a reference');
800 });
Akrona0ea3c32018-12-14 18:33:48 +0100801
802
hebasta999d6c12018-04-23 12:44:59 +0200803
Akronfa32c9d2018-11-20 15:39:18 +0100804 // Meta information should be sorted alphabetically
805 it('should be alphabetically sorted', function(){
806 var a = mel.children[0].children[0].firstChild.nodeValue;
807 var b = mel.children[1].children[0].firstChild.nodeValue;
808 var c = mel.children[2].children[0].firstChild.nodeValue;
809 expect(a.localeCompare(b)).toBe(-1);
810 expect(b.localeCompare(c)).toBe(-1);
Akrona0ea3c32018-12-14 18:33:48 +0100811 });
812
813
814 it('should handle attachements', function () {
815 let uri = attachementClass.create("data:text/plain;title=new,Hallo");
816 expect(uri.contentType).toEqual("text/plain");
817
818 expect(uri.payload).toEqual("Hallo");
819 expect(uri.base64).toBeFalsy();
820 expect(uri.isLink).toBeFalsy();
821 expect(uri.param["title"]).toEqual("new");
822
823 uri = attachementClass.create("data:application/x.korap-link,https://de.wikipedia.org/wiki/Beispiel");
824 expect(uri.contentType).toEqual("application/x.korap-link");
825 expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel");
826 expect(uri.base64).toBeFalsy();
827 expect(uri.isLink).toBeTruthy();
828 expect(uri.inline().textContent).toEqual("https://de.wikipedia.org/wiki/Beispiel");
829 expect(uri.inline().nodeType).toEqual(1);
830 expect(uri.inline().tagName).toEqual("A");
831 expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer");
832
833
834 uri = attachementClass.create("data:application/x.korap-link;title=Das ist ein Titel,https://de.wikipedia.org/wiki/Beispiel");
835 expect(uri.contentType).toEqual("application/x.korap-link");
836 expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel");
837 expect(uri.base64).toBeFalsy();
838 expect(uri.isLink).toBeTruthy();
839 expect(uri.inline().textContent).toEqual("Das ist ein Titel");
840 expect(uri.inline().nodeType).toEqual(1);
841 expect(uri.inline().tagName).toEqual("A");
842 expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer");
843
844
845 uri = attachementClass.create("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D");
846 expect(uri.contentType).toEqual("text/plain");
847 expect(uri.payload).toEqual("Hello, World!");
848 expect(uri.base64).toBeTruthy();
849 expect(uri.isLink).toBeFalsy();
850 expect(uri.inline().nodeType).toEqual(3);
851 expect(uri.inline().textContent).toEqual("Hello, World!");
852
853 uri = attachementClass.create("data:text/plain;title= new ; subTitle = old ;base64,SGVsbG8sIFdvcmxkIQ%3D%3D");
854 expect(uri.contentType).toEqual("text/plain");
855 expect(uri.payload).toEqual("Hello, World!");
856 expect(uri.param["title"]).toEqual("new");
857 expect(uri.param["subTitle"]).toEqual("old");
858 expect(uri.base64).toBeTruthy();
859 expect(uri.isLink).toBeFalsy();
860 expect(uri.inline().nodeType).toEqual(3);
861 expect(uri.inline().textContent).toEqual("Hello, World!");
862 });
hebasta999d6c12018-04-23 12:44:59 +0200863 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000864 // table = view.toTable();
865 // table.sortBy('');
866 // table.element();
867 // tree = view.toTree();
868 // tree.element();
Nils Diewalda297f062015-04-02 00:23:46 +0000869});