blob: 2004d4f7525bcf35bccaae878a01ce94e073551a [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
Akron5dc31172019-05-15 18:43:48 +0200489 expect(table.length()).toBe(4);
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();
Akron5dc31172019-05-15 18:43:48 +0200521 expect(tr.children[4].hasAttribute("title").toBeFalsy();
522 expect(tr.children[5].firstChild.nodeValue).toBe(longString);
523 expect(tr.children[5].getAttribute("title")).toBe(longString);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000524
525 // first row
526 tr = e.children[1].children[0];
527 expect(tr.nodeName).toBe('TR');
528 expect(tr.getAttribute('tabindex')).toEqual('0');
529 expect(tr.children[0].nodeName).toBe('TH');
530 expect(tr.children[0].firstChild.nodeValue).toEqual('cnx');
531 expect(tr.children[1].firstChild.nodeValue).toEqual('l');
532 expect(tr.children[2].firstChild.nodeValue).toEqual('meist');
533 expect(tr.children[3].firstChild.nodeValue).toEqual('deutlich');
Akron47774c42017-07-03 20:14:55 +0200534 expect(tr.children[4].firstChild.firstChild.nodeValue).toEqual('fähig');
535 expect(tr.children[4].lastChild.firstChild.nodeValue).toEqual('leistung');
Nils Diewald7c8ced22015-04-15 19:21:00 +0000536
537 // second row
538 tr = e.children[1].children[1];
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('p');
544 expect(tr.children[2].firstChild.nodeValue).toEqual('ADV');
545 expect(tr.children[3].firstChild.nodeValue).toEqual('A');
Akron47774c42017-07-03 20:14:55 +0200546 expect(tr.children[4].firstChild.firstChild.nodeValue).toEqual('A');
547 expect(tr.children[4].lastChild.firstChild.nodeValue).toEqual('ADJA');
Akronf2279c42017-12-21 13:48:46 +0100548
549 expect(tr.children[4].firstChild.getAttribute("title")).toEqual('Adjective');
550 expect(tr.children[2].getAttribute("title")).toEqual('Adverb');
551
Nils Diewald58141332015-04-07 16:18:45 +0000552 });
Akron7f9a6a32018-07-18 15:05:23 +0200553
554
555 it('should parse into a table view (sync)', function () {
556 var matchElement = matchElementFactory();
557 expect(matchElement.tagName).toEqual('LI');
558
559 // Match
560 expect(matchElement.children[0].tagName).toEqual('DIV');
561
562 // snippet
563 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
564 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
565 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
566
567 // reference
568 expect(matchElement.children[1].classList.contains('ref')).toBeTruthy();
569 expect(matchElement.children[1].firstChild.nodeValue).toEqual('me');
570
571 // not yet
572 expect(matchElement.children[0].children[1]).toBe(undefined);
573
574 /*
575 var info = matchClass.create(matchElement).info();
576 info.showTable();
577 */
578 var matchObj = matchClass.create(matchElement);
579 matchObj.open();
580
581 // Match
582 expect(matchElement.children[0].tagName).toEqual('DIV');
583
584 // snippet
585 expect(matchElement.children[0].children[0].tagName).toEqual('DIV');
586
587 expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy();
588
589 expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check');
590
591 // reference
592
593 expect(matchElement.children[2].classList.contains('ref')).toBeTruthy();
594 expect(matchElement.children[2].childNodes[1].nodeValue).toEqual('me');
595
596 // Add table
597 matchObj.panel.addTable();
598
599 // now
600 var infotable = matchElement.children[1];
601 expect(infotable.tagName).toEqual('DIV');
602
603 expect(infotable.classList.contains('matchinfo')).toBeTruthy();
604
605 expect(infotable.firstChild.firstChild.firstChild.classList.contains('matchtable')).toBeTruthy();
606
607 // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy();
608 });
609
Nils Diewald58141332015-04-07 16:18:45 +0000610 });
Nils Diewalda297f062015-04-02 00:23:46 +0000611
Akron7f9a6a32018-07-18 15:05:23 +0200612 describe('KorAP.RelationsView', function () {
Akrond8692de2018-07-26 13:06:01 +0200613 beforeAll(beforeAllFunc);
614 afterAll(afterAllFunc);
615
Nils Diewald7c8ced22015-04-15 19:21:00 +0000616 var tree;
Nils Diewalda297f062015-04-02 00:23:46 +0000617
Nils Diewald7c8ced22015-04-15 19:21:00 +0000618 it('should be rendered async 1', function (done) {
Akron7f9a6a32018-07-18 15:05:23 +0200619 var matchObj = matchClass.create(match);
620 var relObj = relClass.create(matchObj);
621 expect(relObj).toBeTruthy();
622 relObj.getData(undefined, undefined, "spans", function (y) {
Akron671fdb92017-09-12 18:09:46 +0200623 tree = y;
624 done();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000625 });
626 });
Nils Diewalda297f062015-04-02 00:23:46 +0000627
Nils Diewald7c8ced22015-04-15 19:21:00 +0000628 it('should be rendered async 2', function () {
Akron7f9a6a32018-07-18 15:05:23 +0200629 expect(tree).toBeTruthy();
630 expect(tree.nodes()).toEqual(49);
631
Nils Diewald7c8ced22015-04-15 19:21:00 +0000632 var e = tree.element();
633 expect(e.nodeName).toEqual('svg');
634 expect(e.getElementsByTagName('g').length).toEqual(48);
Nils Diewald58141332015-04-07 16:18:45 +0000635 });
Akron7f9a6a32018-07-18 15:05:23 +0200636
637
638 it('should add a tree view async 2', function () {
639 var matchElement = matchElementFactory();
640 var matchObj = matchClass.create(matchElement);
641 matchObj.open();
642 matchObj.panel.addTree('mate', 'beebop', 'spans', function () {
643 done();
644 });
645
646 // With added tree
647 var tree = matchElement.children[1].firstChild.firstChild.firstChild;
648 expect(tree.tagName).toEqual('DIV');
649 expect(tree.classList.contains('matchtree')).toBeTruthy();
650 expect(tree.children[0].tagName).toEqual('H6');
651 expect(tree.children[0].children[0].tagName).toEqual('SPAN');
652 expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate');
653 expect(tree.children[0].children[1].tagName).toEqual('SPAN');
654 expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop');
655
656 expect(tree.children[1].tagName).toEqual('DIV');
657 });
658
Akron3bdac532019-03-04 13:24:43 +0100659 it('should make the tree downloadable', function () {
660 var treeClass = matchHierClass.create(treeSnippetHierarchy);
661 var treeElement = treeClass.element();
662 expect(treeElement.tagName).toEqual("svg");
663
664 var base64 = treeClass.toBase64();
665 var str = atob(base64);
666 expect(str).toMatch(new RegExp('<defs><style>path'));
667 expect(str).not.toMatch(new RegExp('&nbsp;'));
668 expect(str).toMatch(new RegExp('&amp;'));
669 });
Nils Diewald58141332015-04-07 16:18:45 +0000670 });
Nils Diewalda297f062015-04-02 00:23:46 +0000671
Nils Diewald7c8ced22015-04-15 19:21:00 +0000672
673 describe('KorAP.MatchTreeItem', function () {
Akrond8692de2018-07-26 13:06:01 +0200674 beforeAll(beforeAllFunc);
675 afterAll(afterAllFunc);
676
Nils Diewald7c8ced22015-04-15 19:21:00 +0000677 it('should be initializable', function () {
678 var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c'])
679 expect(mi.element().firstChild.nodeValue).toEqual('cnx/c');
680 expect(mi.lcField()).toEqual(' cnx/c');
681 expect(mi.foundry()).toEqual('cnx');
682 expect(mi.layer()).toEqual('c');
683 });
Nils Diewalda297f062015-04-02 00:23:46 +0000684 });
Nils Diewalda297f062015-04-02 00:23:46 +0000685
686
Akron671fdb92017-09-12 18:09:46 +0200687 describe('KorAP.MatchRelation', function () {
Akrond8692de2018-07-26 13:06:01 +0200688 beforeAll(beforeAllFunc);
689 afterAll(afterAllFunc);
Akron671fdb92017-09-12 18:09:46 +0200690
691 var relExample = "<span class=\"context-left\"></span>" +
692 "<span class=\"match\">" +
693 " <span xml:id=\"token-GOE/AGA/01784-p199\">" +
694 " <span xlink:title=\"malt/d:ADV\" " +
695 " xlink:type=\"simple\" " +
696 " xlink:href=\"#token-GOE/AGA/01784-p199\">dann</span>" +
697 " </span>" +
698 " zog " +
699 " <span xlink:title=\"malt/d:SUBJ\" " +
700 " xlink:type=\"simple\" " +
701 " xlink:href=\"#token-GOE/AGA/01784-p199\">ich</span>" +
702 " <span xml:id=\"token-GOE/AGA/01784-p202\">" +
703 " <span xlink:title=\"malt/d:OBJA\" " +
704 " xlink:type=\"simple\" " +
705 " xlink:href=\"#token-GOE/AGA/01784-p199\">mich</span>" +
706 " </span>" +
707 "</span>" +
708 "<span class=\"context-right\"></span>";
709
710
711 it('should be initializable', function () {
Akrond8692de2018-07-26 13:06:01 +0200712 var tree = matchRelClass.create();
Akron671fdb92017-09-12 18:09:46 +0200713 expect(tree.size()).toBe(0);
714 });
715
716 it('should be parse string data', function () {
Akrond8692de2018-07-26 13:06:01 +0200717 var tree = matchRelClass.create(relExample);
Akron671fdb92017-09-12 18:09:46 +0200718 expect(tree.size()).toBe(4);
719 });
Akron671fdb92017-09-12 18:09:46 +0200720 });
721
722
Nils Diewald7c8ced22015-04-15 19:21:00 +0000723 describe('KorAP.MatchTreeMenu', function () {
Akrond8692de2018-07-26 13:06:01 +0200724 beforeAll(beforeAllFunc);
725 afterAll(afterAllFunc);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000726
727 it('should be initializable', function () {
Akrond8692de2018-07-26 13:06:01 +0200728 var menu = matchTreeMenuClass.create([
Akron671fdb92017-09-12 18:09:46 +0200729 ['cnx/c', 'cnx', 'c'],
730 ['xip/c', 'xip', 'c']
Akrond8692de2018-07-26 13:06:01 +0200731 ], matchTreeItemClass);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000732
Akrond8692de2018-07-26 13:06:01 +0200733 expect(menu.itemClass()).toEqual(matchTreeItemClass);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000734 expect(menu.element().nodeName).toEqual('UL');
Akronaba7a5a2016-08-15 21:58:33 +0200735 expect(menu.element().classList.contains('visible')).toBeFalsy();
Nils Diewald7c8ced22015-04-15 19:21:00 +0000736 expect(menu.limit()).toEqual(6);
737 menu.show();
Akronaba7a5a2016-08-15 21:58:33 +0200738 expect(menu.element().classList.contains('visible')).toBeTruthy();
Akronc1457bf2015-06-11 19:24:00 +0200739 expect(menu.item(0).active()).toBe(false);
Nils Diewald7c8ced22015-04-15 19:21:00 +0000740 });
Nils Diewalda297f062015-04-02 00:23:46 +0000741 });
hebasta999d6c12018-04-23 12:44:59 +0200742
743 //Test display and sorting of meta information
744 describe('KorAP.Meta', function(){
Akrond8692de2018-07-26 13:06:01 +0200745 beforeAll(beforeAllFunc);
746 afterAll(afterAllFunc);
747
748 var met = metaClass.create(match, fields);
hebasta999d6c12018-04-23 12:44:59 +0200749 var mel = met.element();
750
751 // Meta information should be parsed into a list
752 it('should parse in a meta view', function(){
Akronfa32c9d2018-11-20 15:39:18 +0100753 expect(mel.tagName).toEqual('DL');
754 expect(mel.children[0].tagName).toEqual('DIV');
755 expect(mel.children[0].children[0].tagName).toEqual('DT');
756 expect(mel.children[0].children[0].attributes[0].name).toEqual('title');
757 expect(mel.children[0].children[1].tagName).toEqual('DD');
758 expect(mel.children[0].children[1].getAttribute('data-type')).toEqual('type:text')
hebasta999d6c12018-04-23 12:44:59 +0200759
Akronfa32c9d2018-11-20 15:39:18 +0100760 expect(mel.children[0].children[0].firstChild.nodeValue).toEqual('author');
761 expect(mel.children[0].children[1].firstChild.nodeValue).toEqual('Sprachpfleger, u.a.');
762 expect(mel.children[0].children[0].attributes[0].value).toEqual('author');
hebasta999d6c12018-04-23 12:44:59 +0200763 });
764
765
Akronfa32c9d2018-11-20 15:39:18 +0100766 /* The keywords in the meta information list should be formatted to be able
767 to chose each keyword separately in the corpusByMatch assistant. */
768 it('keywords should be formatted', function(){
hebasta999d6c12018-04-23 12:44:59 +0200769
Akronfa32c9d2018-11-20 15:39:18 +0100770 //type:string or type:keyword should b not relevant
771 expect(mel.children[1].children[1].getAttribute('data-type')).toEqual('type:string')
772 expect(mel.children[1].children[1].classList.contains('metakeyvalues')).toBeTruthy;
773 expect(mel.children[1].children[1].children[0].tagName).toEqual('DIV');
774 expect(mel.children[1].children[1].children[0].firstChild.nodeValue).toEqual('corenlp');
775 expect(mel.children[1].children[1].children[1].tagName).toEqual('DIV');
776 expect(mel.children[1].children[1].children[1].firstChild.nodeValue).toEqual('corenlp\/constituency');
777
778 expect(mel.children[2].children[1].classList.contains('metakeyvalues')).toBeTruthy;
779 expect(mel.children[2].children[1].children[0].tagName).toEqual('DIV');
780 expect(mel.children[2].children[1].children[0].firstChild.nodeValue).toEqual('kultur');
781 expect(mel.children[2].children[1].children[1].tagName).toEqual('DIV');
782 expect(mel.children[2].children[1].children[1].firstChild.nodeValue).toEqual('film');
hebasta999d6c12018-04-23 12:44:59 +0200783 });
Akrona0ea3c32018-12-14 18:33:48 +0100784
785 it('attachements should be formatted', function(){
Akrond3bb85b2019-02-08 10:15:13 +0100786 //type:attachement with a link
Akrona0ea3c32018-12-14 18:33:48 +0100787 expect(mel.children[3].children[1].getAttribute('data-type')).toEqual('type:attachement')
788 expect(mel.children[3].children[1].classList.contains('metakeyvalues')).toBeFalsy;
789 expect(mel.children[3].children[0].firstChild.nodeValue).toEqual('xlink');
790 expect(mel.children[3].children[1].firstChild.textContent).toEqual('Cool');
791 expect(mel.children[3].children[1].firstChild.tagName).toEqual('A');
792 expect(mel.children[3].children[1].firstChild.getAttribute('href')).toEqual('https://de.wikipedia.org/wiki/Beispiel');
Akrond3bb85b2019-02-08 10:15:13 +0100793
794 //type:attachement with plain text
795 expect(mel.children[4].children[1].getAttribute('data-type')).toEqual('type:attachement')
796 expect(mel.children[4].children[1].classList.contains('metakeyvalues')).toBeFalsy;
797 expect(mel.children[4].children[0].firstChild.nodeValue).toEqual('z-reference');
798 expect(mel.children[4].children[1].firstChild.nodeValue).toEqual('This is a reference');
799 });
Akrona0ea3c32018-12-14 18:33:48 +0100800
801
hebasta999d6c12018-04-23 12:44:59 +0200802
Akronfa32c9d2018-11-20 15:39:18 +0100803 // Meta information should be sorted alphabetically
804 it('should be alphabetically sorted', function(){
805 var a = mel.children[0].children[0].firstChild.nodeValue;
806 var b = mel.children[1].children[0].firstChild.nodeValue;
807 var c = mel.children[2].children[0].firstChild.nodeValue;
808 expect(a.localeCompare(b)).toBe(-1);
809 expect(b.localeCompare(c)).toBe(-1);
Akrona0ea3c32018-12-14 18:33:48 +0100810 });
811
812
813 it('should handle attachements', function () {
814 let uri = attachementClass.create("data:text/plain;title=new,Hallo");
815 expect(uri.contentType).toEqual("text/plain");
816
817 expect(uri.payload).toEqual("Hallo");
818 expect(uri.base64).toBeFalsy();
819 expect(uri.isLink).toBeFalsy();
820 expect(uri.param["title"]).toEqual("new");
821
822 uri = attachementClass.create("data:application/x.korap-link,https://de.wikipedia.org/wiki/Beispiel");
823 expect(uri.contentType).toEqual("application/x.korap-link");
824 expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel");
825 expect(uri.base64).toBeFalsy();
826 expect(uri.isLink).toBeTruthy();
827 expect(uri.inline().textContent).toEqual("https://de.wikipedia.org/wiki/Beispiel");
828 expect(uri.inline().nodeType).toEqual(1);
829 expect(uri.inline().tagName).toEqual("A");
830 expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer");
831
832
833 uri = attachementClass.create("data:application/x.korap-link;title=Das ist ein Titel,https://de.wikipedia.org/wiki/Beispiel");
834 expect(uri.contentType).toEqual("application/x.korap-link");
835 expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel");
836 expect(uri.base64).toBeFalsy();
837 expect(uri.isLink).toBeTruthy();
838 expect(uri.inline().textContent).toEqual("Das ist ein Titel");
839 expect(uri.inline().nodeType).toEqual(1);
840 expect(uri.inline().tagName).toEqual("A");
841 expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer");
842
843
844 uri = attachementClass.create("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D");
845 expect(uri.contentType).toEqual("text/plain");
846 expect(uri.payload).toEqual("Hello, World!");
847 expect(uri.base64).toBeTruthy();
848 expect(uri.isLink).toBeFalsy();
849 expect(uri.inline().nodeType).toEqual(3);
850 expect(uri.inline().textContent).toEqual("Hello, World!");
851
852 uri = attachementClass.create("data:text/plain;title= new ; subTitle = old ;base64,SGVsbG8sIFdvcmxkIQ%3D%3D");
853 expect(uri.contentType).toEqual("text/plain");
854 expect(uri.payload).toEqual("Hello, World!");
855 expect(uri.param["title"]).toEqual("new");
856 expect(uri.param["subTitle"]).toEqual("old");
857 expect(uri.base64).toBeTruthy();
858 expect(uri.isLink).toBeFalsy();
859 expect(uri.inline().nodeType).toEqual(3);
860 expect(uri.inline().textContent).toEqual("Hello, World!");
861 });
hebasta999d6c12018-04-23 12:44:59 +0200862 });
Nils Diewald7c8ced22015-04-15 19:21:00 +0000863 // table = view.toTable();
864 // table.sortBy('');
865 // table.element();
866 // tree = view.toTree();
867 // tree.element();
Nils Diewalda297f062015-04-02 00:23:46 +0000868});