Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 1 | // Regarding async: |
| 2 | // http://stackoverflow.com/questions/16423156/getting-requirejs-to-work-with-jasmine |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 3 | define(['match', |
| 4 | 'view/match/tokentable', |
| 5 | 'view/match/relations', |
| 6 | 'panel/match', |
| 7 | 'match/meta', |
| 8 | 'match/infolayer', |
| 9 | 'match/treeitem', |
| 10 | 'match/treearc', |
Akron | 3bdac53 | 2019-03-04 13:24:43 +0100 | [diff] [blame] | 11 | 'match/treehierarchy', |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 12 | 'buttongroup/menu', |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 13 | 'match/attachement', |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 14 | 'hint/foundries/cnx', |
| 15 | 'hint/foundries/mate'], function ( |
| 16 | matchClass, |
| 17 | tableClass, |
| 18 | relClass, |
| 19 | panelClass, |
| 20 | metaClass, |
| 21 | infoClass, |
| 22 | matchTreeItemClass, |
| 23 | matchRelClass, |
Akron | 3bdac53 | 2019-03-04 13:24:43 +0100 | [diff] [blame] | 24 | matchHierClass, |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 25 | matchTreeMenuClass, |
| 26 | attachementClass) { |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 27 | |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 28 | 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 Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 44 | |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 45 | var match = { |
| 46 | 'corpusID' : 'WPD', |
| 47 | 'docID' : 'UUU', |
| 48 | 'textID' : '01912', |
| 49 | 'matchID' : 'p121-122', |
| 50 | 'textSigle' : 'WPD/UUU/01912', |
| 51 | 'available' : available |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 52 | }; |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 53 | |
| 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", |
Akron | d45a170 | 2018-11-19 18:15:17 +0100 | [diff] [blame] | 65 | "type": "type:keywords", // May not be necessary |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 66 | "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 | ] |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 84 | }, |
| 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 | }, |
Akron | d3bb85b | 2019-02-08 10:15:13 +0100 | [diff] [blame] | 91 | { |
| 92 | "@type": "koral:field", |
Akron | 0f70076 | 2022-01-11 17:21:16 +0100 | [diff] [blame^] | 93 | "key": "xlink2", |
| 94 | "type": "type:attachement", |
| 95 | "value": "data:application/x.korap-link;example=%20Das%20war%20einfach;title=Hallo%21,https%3A%2F%2Fwww.test.de" |
| 96 | }, |
| 97 | { |
| 98 | "@type": "koral:field", |
Akron | d3bb85b | 2019-02-08 10:15:13 +0100 | [diff] [blame] | 99 | "key": "z-reference", |
| 100 | "type": "type:attachement", |
| 101 | "value": "data:,This is a reference" |
| 102 | } |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 103 | ]; |
| 104 | |
| 105 | |
Akron | 5dc3117 | 2019-05-15 18:43:48 +0200 | [diff] [blame] | 106 | var snippet = "<span class=\"context-left\"><\/span>"+ |
| 107 | "<span class=\"match\">" + |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 108 | "<span class=\"cutted\"><\/span>" + |
| 109 | "Außerdem " + |
Akron | 5dc3117 | 2019-05-15 18:43:48 +0200 | [diff] [blame] | 110 | "<span title=\"cnx/l:meist\">" + |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 111 | " <span title=\"cnx/p:ADV\">" + |
| 112 | " <span title=\"cnx/syn:@PREMOD\">" + |
| 113 | " <span title=\"mate/l:meist\">" + |
| 114 | " <span title=\"mate/l:meist\">" + |
| 115 | " <span title=\"mate/p:ADV\">" + |
| 116 | " <span title=\"opennlp/p:ADV\">meist</span>" + |
| 117 | " </span>" + |
| 118 | " </span>" + |
| 119 | " </span>" + |
| 120 | " </span>" + |
| 121 | " </span>" + |
| 122 | "</span>" + |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 123 | "<mark>" + |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 124 | "<span title=\"cnx/l:deutlich\">" + |
| 125 | " <span title=\"cnx/p:A\">" + |
| 126 | " <span title=\"cnx/syn:@PREMOD\">" + |
| 127 | " <span title=\"mate/l:deutlich\">" + |
| 128 | " <span title=\"mate/m:degree:pos\">" + |
| 129 | " <span title=\"mate/p:ADJD\">" + |
| 130 | " <span title=\"opennlp/p:ADJD\">deutlich</span>" + |
| 131 | " </span>" + |
| 132 | " </span>" + |
| 133 | " </span>" + |
| 134 | " </span>" + |
| 135 | " </span>" + |
| 136 | "</span>" + |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 137 | "</mark>" + |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 138 | "<span title=\"dgd/para:incident\">▮</span>" + |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 139 | "<span title=\"cnx/l:fähig\">" + |
| 140 | " <span title=\"cnx/l:leistung\">" + |
| 141 | " <span title=\"cnx/p:A\">" + |
| 142 | " <span title=\"cnx/p:ADJA\">" + |
| 143 | " <span title=\"cnx/syn:@NH\">" + |
| 144 | " <span title=\"mate/l:leistungsfähig\">" + |
| 145 | " <span title=\"mate/m:degree:comp\">" + |
| 146 | " <span title=\"mate/p:ADJD\">" + |
| 147 | " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" + |
| 148 | " </span>" + |
| 149 | " </span>" + |
| 150 | " </span>" + |
| 151 | " </span>" + |
| 152 | " </span>" + |
| 153 | " </span>" + |
| 154 | " </span>" + |
Akron | 5dc3117 | 2019-05-15 18:43:48 +0200 | [diff] [blame] | 155 | "</span>" + |
| 156 | " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können." + |
| 157 | "<span class=\"cutted\"><\/span>" + |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 158 | "</span>"; |
| 159 | |
| 160 | var treeSnippet = |
| 161 | "<span class=\"context-left\"></span>" + |
| 162 | "<span class=\"match\">" + |
| 163 | " <span title=\"xip/c:MC\">" + |
| 164 | " <span title=\"xip/c:TOP\">" + |
| 165 | " <span title=\"xip/c:PP\">" + |
| 166 | " <span title=\"xip/c:PREP\">Mit</span>" + |
| 167 | " <span title=\"xip/c:NP\">" + |
| 168 | " <span title=\"xip/c:DET\">dieser</span>" + |
| 169 | " <span title=\"xip/c:NPA\">" + |
| 170 | " <span title=\"xip/c:NOUN\">Methode</span>" + |
| 171 | " </span>" + |
| 172 | " </span>" + |
| 173 | " </span>" + |
| 174 | " <span title=\"xip/c:VERB\">ist</span>" + |
| 175 | " <mark>" + |
| 176 | " <span title=\"xip/c:NP\">" + |
| 177 | " <span title=\"xip/c:PRON\">es</span>" + |
| 178 | " </span>" + |
| 179 | " <span title=\"xip/c:AP\">" + |
| 180 | " <span title=\"xip/c:ADV\">nun</span>" + |
| 181 | " <span title=\"xip/c:ADJ\">möglich</span>" + |
| 182 | " </span>" + |
| 183 | " </mark>" + |
| 184 | " <span title=\"xip/c:ADV\">z. B.</span>" + |
| 185 | " <span title=\"xip/c:NPA\">" + |
| 186 | " <span title=\"xip/c:NP\">" + |
| 187 | " <span title=\"xip/c:NOUN\">Voice</span>" + |
| 188 | " </span>" + |
| 189 | " </span>" + "(" + |
| 190 | " <span title=\"xip/c:INS\">" + |
| 191 | " <span title=\"xip/c:NPA\">" + |
| 192 | " <span title=\"xip/c:NP\">" + |
| 193 | " <span title=\"xip/c:NOUN\">Sprache</span>" + |
| 194 | " </span>" + |
| 195 | " </span>" + |
| 196 | " </span>" + ")" + |
| 197 | " <span title=\"xip/c:VERB\">bevorzugt</span>" + |
| 198 | " <span title=\"xip/c:PP\">" + |
| 199 | " <span title=\"xip/c:PREP\">in</span>" + |
| 200 | " <span title=\"xip/c:NP\">" + |
| 201 | " <span title=\"xip/c:PRON\">der</span>" + |
| 202 | " </span>" + |
| 203 | " <span title=\"xip/c:NPA\">" + |
| 204 | " <span title=\"xip/c:NP\">" + |
| 205 | " <span title=\"xip/c:NOUN\">Bridge</span>" + |
| 206 | " </span>" + |
| 207 | " </span>" + |
| 208 | " </span>" + |
| 209 | " <span title=\"xip/c:INFC\">" + |
| 210 | " <span title=\"xip/c:INS\">" + |
| 211 | " <span title=\"xip/c:VERB\">weiterzugeben</span>" + |
| 212 | " </span>" + |
| 213 | " </span>" + |
| 214 | " </span>" + |
| 215 | " </span>" + |
| 216 | "</span>" + |
| 217 | "<span class=\"context-right\"></span>"; |
| 218 | |
Akron | 3bdac53 | 2019-03-04 13:24:43 +0100 | [diff] [blame] | 219 | var treeSnippetHierarchy = |
| 220 | "<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>“.<<span title=\"corenlp\/c:S\"><span title=\"corenlp\/c:ROOT\"><span title=\"corenlp\/c:NP\">ref>''<span title=\"corenlp\/c:NP\"><span title=\"corenlp\/c:CNP\">Movie &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>"; |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 221 | |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 222 | function matchElementFactory () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 223 | var me = document.createElement('li'); |
| 224 | |
| 225 | me.setAttribute( |
| 226 | 'data-available-info', |
| 227 | 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' + |
| 228 | ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' + |
| 229 | ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' + |
| 230 | ' tt/p=tokens tt/s=spans'); |
| 231 | |
| 232 | me.setAttribute('data-corpus-id', 'WPD'); |
| 233 | me.setAttribute('data-doc-id', 'FFF'); |
| 234 | me.setAttribute('data-text-id', '01460'); |
| 235 | me.setAttribute('data-text-sigle', 'WPD/FFF/01460'); |
| 236 | me.setAttribute('data-match-id', 'p119-120'); |
| 237 | me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>'; |
| 238 | return me; |
| 239 | }; |
| 240 | |
| 241 | function matchElementReal () { |
| 242 | var me = document.createElement('em'); |
| 243 | me.innerHTML = |
| 244 | '<li data-match-id="p85183-85184"' + |
| 245 | ' data-text-sigle="GOE/AGI/00000"' + |
| 246 | ' 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"' + |
| 247 | ' data-info="{"UID":0,"author":"Goethe, Johann Wolfgang von","corpusID":null,"corpusSigle":"GOE","docID":null,"docSigle":"GOE\/AGI","layerInfos":"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","matchID":"match-GOE\/AGI\/00000-p85183-85184","pubDate":"1982","pubPlace":"München","subTitle":"Auch ich in Arkadien!","textID":null,"textSigle":"GOE\/AGI\/00000","title":"Italienische Reise"}"' + |
| 248 | ' id="GOE/AGI/00000#p85183-85184">' + |
| 249 | '<div>' + |
| 250 | '<div class="flag"></div>' + |
| 251 | '<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>' + |
| 252 | '</div>' + |
| 253 | '<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>' + |
| 254 | '</li>'; |
| 255 | return me.firstChild; |
| 256 | }; |
| 257 | |
| 258 | var beforeAllFunc = function () { |
| 259 | // Override getMatchInfo API call |
| 260 | KorAP.API.getMatchInfo = function (x, param, cb) { |
| 261 | if (param['spans'] === undefined || param['spans'] === false) |
| 262 | cb({ "snippet": snippet }); |
| 263 | else |
| 264 | cb({ "snippet": treeSnippet }); |
| 265 | }; |
| 266 | }; |
| 267 | |
| 268 | var afterAllFunc = function () { |
| 269 | KorAP.API.getMatchInfo = undefined; |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 270 | KorAP.TreeMenu = undefined; |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 271 | var body = document.body; |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 272 | var i = body.children.length - 1; |
| 273 | while (i >= 0) { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 274 | if (body.children[i].nodeType && body.children[i].nodeType === 1) { |
| 275 | if (!body.children[i].classList.contains("jasmine_html-reporter")) { |
| 276 | body.removeChild(body.children[i]); |
| 277 | }; |
| 278 | }; |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 279 | i--; |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 280 | }; |
| 281 | }; |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 282 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 283 | describe('KorAP.InfoLayer', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 284 | beforeAll(beforeAllFunc); |
| 285 | afterAll(afterAllFunc); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 286 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 287 | it('should be initializable', function () { |
| 288 | expect( |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 289 | function() { infoClass.create() } |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 290 | ).toThrow(new Error("Missing parameters")); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 291 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 292 | expect( |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 293 | function() { infoClass.create("base") } |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 294 | ).toThrow(new Error("Missing parameters")); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 295 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 296 | var layer = infoClass.create("base", "s"); |
| 297 | expect(layer).toBeTruthy(); |
| 298 | expect(layer.foundry).toEqual("base"); |
| 299 | expect(layer.layer).toEqual("s"); |
| 300 | expect(layer.type).toEqual("tokens"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 301 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 302 | layer = infoClass.create("cnx", "syn", "spans"); |
| 303 | expect(layer).toBeTruthy(); |
| 304 | expect(layer.foundry).toEqual("cnx"); |
| 305 | expect(layer.layer).toEqual("syn"); |
| 306 | expect(layer.type).toEqual("spans"); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 307 | }); |
| 308 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 309 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 310 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 311 | describe('KorAP.Match', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 312 | beforeAll(beforeAllFunc); |
| 313 | afterAll(afterAllFunc); |
| 314 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 315 | var match = { |
| 316 | 'corpusID' : 'WPD', |
| 317 | 'docID' : 'UUU', |
| 318 | 'textID' : '01912', |
| 319 | 'matchID' : 'p121-122', |
Akron | 0a6768f | 2016-07-13 18:00:43 +0200 | [diff] [blame] | 320 | 'textSigle' : 'WPD/UUU/01912', |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 321 | 'available' : available |
| 322 | }; |
| 323 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 324 | it('should be initializable by Object', function () { |
| 325 | expect(function() { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 326 | matchClass.create() |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 327 | }).toThrow(new Error('Missing parameters')); |
| 328 | |
| 329 | expect(matchClass.create(match)).toBeTruthy(); |
| 330 | |
| 331 | var m = matchClass.create(match); |
Akron | 0a6768f | 2016-07-13 18:00:43 +0200 | [diff] [blame] | 332 | expect(m.textSigle).toEqual("WPD/UUU/01912"); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 333 | expect(m.matchID).toEqual("p121-122"); |
| 334 | |
| 335 | // /corpus/WPD/UUU.01912/p121-122/matchInfo?spans=false&foundry=* |
| 336 | var m = matchClass.create(match); |
| 337 | |
| 338 | // Spans: |
| 339 | var spans = m.getSpans(); |
| 340 | expect(spans[0].foundry).toEqual("base"); |
| 341 | expect(spans[0].layer).toEqual("s"); |
| 342 | |
| 343 | expect(spans[1].foundry).toEqual("corenlp"); |
| 344 | expect(spans[1].layer).toEqual("c"); |
| 345 | |
| 346 | expect(spans[2].foundry).toEqual("corenlp"); |
| 347 | expect(spans[2].layer).toEqual("s"); |
| 348 | |
| 349 | expect(spans[spans.length-1].foundry).toEqual("tt"); |
| 350 | expect(spans[spans.length-1].layer).toEqual("s"); |
| 351 | |
| 352 | // Tokens: |
| 353 | var tokens = m.getTokens(); |
| 354 | expect(tokens[0].foundry).toEqual("corenlp"); |
| 355 | expect(tokens[0].layer).toEqual("ne"); |
| 356 | |
| 357 | expect(tokens[1].foundry).toEqual("corenlp"); |
| 358 | expect(tokens[1].layer).toEqual("p"); |
| 359 | |
| 360 | expect(tokens[tokens.length-1].foundry).toEqual("tt"); |
| 361 | expect(tokens[tokens.length-1].layer).toEqual("p"); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 362 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 363 | |
| 364 | |
Akron | cdb0baa | 2016-11-07 01:52:11 +0100 | [diff] [blame] | 365 | it('should be initializable by Node 1', function () { |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 366 | var m = matchClass.create(matchElementFactory()); |
Akron | 0a6768f | 2016-07-13 18:00:43 +0200 | [diff] [blame] | 367 | expect(m.textSigle).toEqual("WPD/FFF/01460"); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 368 | expect(m.matchID).toEqual("p119-120"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 369 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 370 | // Spans: |
| 371 | var spans = m.getSpans(); |
| 372 | expect(spans[0].foundry).toEqual("base"); |
| 373 | expect(spans[0].layer).toEqual("s"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 374 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 375 | expect(spans[1].foundry).toEqual("corenlp"); |
| 376 | expect(spans[1].layer).toEqual("c"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 377 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 378 | expect(spans[2].foundry).toEqual("corenlp"); |
| 379 | expect(spans[2].layer).toEqual("s"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 380 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 381 | expect(spans[spans.length-1].foundry).toEqual("tt"); |
| 382 | expect(spans[spans.length-1].layer).toEqual("s"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 383 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 384 | // Tokens: |
| 385 | var tokens = m.getTokens(); |
| 386 | expect(tokens[0].foundry).toEqual("corenlp"); |
| 387 | expect(tokens[0].layer).toEqual("ne"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 388 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 389 | expect(tokens[1].foundry).toEqual("corenlp"); |
| 390 | expect(tokens[1].layer).toEqual("p"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 391 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 392 | expect(tokens[tokens.length-1].foundry).toEqual("tt"); |
| 393 | expect(tokens[tokens.length-1].layer).toEqual("p"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 394 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 395 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 396 | |
Akron | cdb0baa | 2016-11-07 01:52:11 +0100 | [diff] [blame] | 397 | it('should be initializable by Node 2', function () { |
| 398 | var ele = matchElementReal(); |
| 399 | var m = matchClass.create(ele); |
| 400 | expect(m.textSigle).toEqual("GOE/AGI/00000"); |
| 401 | expect(m.matchID).toEqual("p85183-85184"); |
| 402 | }); |
| 403 | |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 404 | it('should be initializable when active', function () { |
| 405 | var e = matchElementFactory(); |
| 406 | e.setAttribute('class', 'active'); |
| 407 | |
| 408 | expect(e.classList.contains('active')).toBe(true); |
| 409 | expect(e["_match"]).toBe(undefined); |
| 410 | |
| 411 | var m = matchClass.create(e); |
| 412 | |
| 413 | expect(e["_match"]).not.toBe(undefined); |
| 414 | |
| 415 | // Open the match |
| 416 | m.init(); |
| 417 | |
| 418 | expect(e["_match"]).not.toBe(undefined); |
| 419 | |
| 420 | actions = e.querySelector("p.ref > div.action.button-group").children; |
| 421 | |
| 422 | expect(actions[0].getAttribute("class")).toEqual("metatable"); |
| 423 | expect(actions[1].getAttribute("class")).toEqual("info"); |
| 424 | expect(actions[2].getAttribute("class")).toEqual("tree"); |
| 425 | |
| 426 | // Close the match |
| 427 | expect(e.querySelector("div.action.button-group > span.minimize")).toBe(null); |
| 428 | }); |
Akron | cdb0baa | 2016-11-07 01:52:11 +0100 | [diff] [blame] | 429 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 430 | it('should react to gui actions', function () { |
| 431 | var e = matchElementFactory(); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 432 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 433 | expect(e.classList.contains('active')).toBe(false); |
| 434 | expect(e["_match"]).toBe(undefined); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 435 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 436 | var m = matchClass.create(e); |
| 437 | |
| 438 | expect(e.classList.contains('active')).toBe(false); |
| 439 | expect(e["_match"]).not.toBe(undefined); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 440 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 441 | // Open the match |
| 442 | m.open(); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 443 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 444 | expect(e.classList.contains('active')).toBe(true); |
| 445 | expect(e["_match"]).not.toBe(undefined); |
| 446 | |
Akron | bfe912c | 2018-07-17 19:30:52 +0200 | [diff] [blame] | 447 | actions = e.querySelector("p.ref > div.action.button-group").children; |
Akron | d141a36 | 2018-07-10 18:12:13 +0200 | [diff] [blame] | 448 | |
Akron | bfe912c | 2018-07-17 19:30:52 +0200 | [diff] [blame] | 449 | expect(actions[0].getAttribute("class")).toEqual("metatable"); |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 450 | expect(actions[1].getAttribute("class")).toEqual("info"); |
| 451 | expect(actions[2].getAttribute("class")).toEqual("tree"); |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 452 | |
| 453 | expect(e.querySelector("div.action.button-group > span.minimize")).not.toBe(null); |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 454 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 455 | // Close the match |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 456 | m.minimize(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 457 | expect(e.classList.contains('active')).toBe(false); |
| 458 | expect(e["_match"]).not.toBe(undefined); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 459 | }); |
Akron | e57e880 | 2020-10-17 08:23:45 +0200 | [diff] [blame] | 460 | |
| 461 | it('should toggle', function () { |
| 462 | var e = matchElementFactory(); |
| 463 | |
| 464 | expect(e.classList.contains('active')).toBe(false); |
| 465 | expect(e["_match"]).toBe(undefined); |
| 466 | |
| 467 | var m = matchClass.create(e); |
| 468 | |
| 469 | expect(e.classList.contains('active')).toBe(false); |
| 470 | expect(e["_match"]).not.toBe(undefined); |
| 471 | |
| 472 | // Open the match |
| 473 | m.open(); |
| 474 | |
| 475 | expect(e.classList.contains('active')).toBe(true); |
| 476 | expect(e["_match"]).not.toBe(undefined); |
| 477 | |
| 478 | m.toggle(); |
| 479 | |
| 480 | expect(e.classList.contains('active')).toBe(false); |
| 481 | expect(e["_match"]).not.toBe(undefined); |
| 482 | |
| 483 | m.toggle(); |
| 484 | |
| 485 | expect(e.classList.contains('active')).toBe(true); |
| 486 | expect(e["_match"]).not.toBe(undefined); |
| 487 | }); |
| 488 | |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 489 | it('should open tree menu', function () { |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 490 | var e = matchElementFactory(); |
| 491 | var m = matchClass.create(e); |
| 492 | m.open(); |
Akron | bfe912c | 2018-07-17 19:30:52 +0200 | [diff] [blame] | 493 | var relation = e.querySelector("p.ref > div.action.button-group > span:nth-of-type(3)"); |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 494 | expect(relation.getAttribute("class")).toEqual("tree"); |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 495 | expect(document.getElementsByClassName("button-group-list").length).toEqual(0); |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 496 | expect(document.activeElement.tagName).toEqual("BODY"); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 497 | |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 498 | // Show menu |
| 499 | relation.click(); |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 500 | expect(document.getElementsByClassName("button-group-list").length).toEqual(1); |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 501 | expect(document.activeElement.tagName).toEqual("UL"); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 502 | |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 503 | // Choose first tree |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 504 | document.getElementsByClassName("button-group-list")[0].getElementsByTagName("li")[1].click(); |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 505 | expect(e.querySelector("div.matchinfo div.matchtree h6 span").innerText).toEqual("corenlp"); |
| 506 | |
| 507 | // This should blur the focus |
| 508 | expect(document.activeElement.tagName).toEqual("BODY"); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 509 | |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 510 | }); |
| 511 | |
| 512 | }); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 513 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 514 | describe('KorAP.TableView', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 515 | beforeAll(beforeAllFunc); |
| 516 | afterAll(afterAllFunc); |
Akron | 5dc3117 | 2019-05-15 18:43:48 +0200 | [diff] [blame] | 517 | |
| 518 | let longString = " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können."; |
| 519 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 520 | var table; |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 521 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 522 | var matchObj = matchClass.create(match); |
| 523 | var tableObj = tableClass.create(matchObj); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 524 | |
| 525 | var table1, table2; |
| 526 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 527 | it('should fail to load a table async', function (done) { |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 528 | expect(tableObj).toBeTruthy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 529 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 530 | tableObj.getData([], function (tablen) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 531 | table1 = tablen; |
| 532 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 533 | }); |
| 534 | }); |
| 535 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 536 | |
Akron | aeeb825 | 2018-09-19 18:51:00 +0200 | [diff] [blame] | 537 | xit('should\'nt be parsable (async)', function () { |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 538 | expect(table1).not.toBeTruthy(); |
| 539 | }); |
| 540 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 541 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 542 | it('should be retrieved async', function (done) { |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 543 | expect(tableObj).toBeTruthy(); |
| 544 | tableObj.getData(undefined, function (x) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 545 | table = x; |
| 546 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 547 | }); |
| 548 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 549 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 550 | it('should parse into a table (async)', function () { |
| 551 | expect(table).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame] | 552 | |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 553 | expect(table.length()).toBe(8); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 554 | |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 555 | expect(table.getToken(0)).toBe(""); |
| 556 | expect(table.getToken(1)).toBe("Außerdem "); |
| 557 | expect(table.getToken(2)).toBe("meist"); |
| 558 | expect(table.getToken(3)).toBe("deutlich"); |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 559 | expect(table.getToken(5)).toBe("leistungsfähiger"); |
| 560 | expect(table.getToken(6)).toBe(longString); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 561 | |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 562 | expect(table.getValue(2, "cnx", "p")[0]).toBe("ADV"); |
| 563 | expect(table.getValue(2, "cnx", "syn")[0]).toBe("@PREMOD"); |
| 564 | expect(table.getValue(2, "mate", "l")[0]).toBe("meist"); |
| 565 | expect(table.getValue(2, "mate", "l")[1]).toBeUndefined(); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 566 | |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 567 | expect(table.getValue(5, "cnx", "l")[0]).toBe("fähig"); |
| 568 | expect(table.getValue(5, "cnx", "l")[1]).toBe("leistung"); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 569 | }); |
| 570 | |
| 571 | it('should be rendered async', function () { |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame] | 572 | var e = table.element().firstChild; |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 573 | expect(e.nodeName).toBe('TABLE'); |
| 574 | expect(e.children[0].nodeName).toBe('THEAD'); |
| 575 | var tr = e.children[0].children[0]; |
| 576 | expect(tr.nodeName).toBe('TR'); |
| 577 | expect(tr.children[0].nodeName).toBe('TH'); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 578 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 579 | expect(tr.children[0].firstChild.nodeValue).toBe('Foundry'); |
| 580 | expect(tr.children[1].firstChild.nodeValue).toBe('Layer'); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 581 | |
| 582 | expect(tr.children[2].classList.contains('cutted')).toBeTruthy(); |
| 583 | expect(tr.children[3].firstChild.nodeValue).toBe('Außerdem '); |
| 584 | |
| 585 | |
| 586 | expect(tr.children[4].firstChild.nodeValue).toBe('meist'); |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 587 | expect(tr.children[4].classList.contains('mark')).toBeFalsy(); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 588 | expect(tr.children[5].firstChild.nodeValue).toBe('deutlich'); |
| 589 | expect(tr.children[5].classList.contains('mark')).toBeTruthy(); |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 590 | expect(tr.children[6].firstChild.nodeValue).toBe('▮'); |
| 591 | expect(tr.children[7].firstChild.nodeValue).toBe('leistungsfähiger'); |
| 592 | expect(tr.children[7].classList.contains('mark')).toBeFalsy(); |
| 593 | expect(tr.children[7].hasAttribute("title")).toBeFalsy(); |
| 594 | expect(tr.children[8].firstChild.nodeValue).toBe(longString); |
| 595 | expect(tr.children[8].getAttribute("title")).toBe(longString); |
| 596 | expect(tr.children[9].classList.contains('cutted')).toBeTruthy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 597 | |
| 598 | // first row |
| 599 | tr = e.children[1].children[0]; |
| 600 | expect(tr.nodeName).toBe('TR'); |
| 601 | expect(tr.getAttribute('tabindex')).toEqual('0'); |
| 602 | expect(tr.children[0].nodeName).toBe('TH'); |
| 603 | expect(tr.children[0].firstChild.nodeValue).toEqual('cnx'); |
| 604 | expect(tr.children[1].firstChild.nodeValue).toEqual('l'); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 605 | expect(tr.children[4].firstChild.nodeValue).toEqual('meist'); |
| 606 | expect(tr.children[5].firstChild.nodeValue).toEqual('deutlich'); |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 607 | expect(tr.children[6].firstChild).toBeNull(); |
| 608 | expect(tr.children[7].firstChild.firstChild.nodeValue).toEqual('fähig'); |
| 609 | expect(tr.children[7].lastChild.firstChild.nodeValue).toEqual('leistung'); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 610 | |
| 611 | // second row |
| 612 | tr = e.children[1].children[1]; |
| 613 | expect(tr.nodeName).toBe('TR'); |
| 614 | expect(tr.getAttribute('tabindex')).toEqual('0'); |
| 615 | expect(tr.children[0].nodeName).toBe('TH'); |
| 616 | expect(tr.children[0].firstChild.nodeValue).toEqual('cnx'); |
| 617 | expect(tr.children[1].firstChild.nodeValue).toEqual('p'); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 618 | expect(tr.children[4].firstChild.nodeValue).toEqual('ADV'); |
| 619 | expect(tr.children[5].firstChild.nodeValue).toEqual('A'); |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 620 | expect(tr.children[6].firstChild).toBeNull(); |
| 621 | expect(tr.children[7].firstChild.firstChild.nodeValue).toEqual('A'); |
| 622 | expect(tr.children[7].lastChild.firstChild.nodeValue).toEqual('ADJA'); |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 623 | |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 624 | expect(tr.children[7].firstChild.getAttribute("title")).toEqual('Adjective'); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 625 | expect(tr.children[4].getAttribute("title")).toEqual('Adverb'); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 626 | }); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 627 | |
| 628 | |
| 629 | it('should parse into a table view (sync)', function () { |
| 630 | var matchElement = matchElementFactory(); |
| 631 | expect(matchElement.tagName).toEqual('LI'); |
| 632 | |
| 633 | // Match |
| 634 | expect(matchElement.children[0].tagName).toEqual('DIV'); |
| 635 | |
| 636 | // snippet |
| 637 | expect(matchElement.children[0].children[0].tagName).toEqual('DIV'); |
| 638 | expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy(); |
| 639 | expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check'); |
| 640 | |
| 641 | // reference |
| 642 | expect(matchElement.children[1].classList.contains('ref')).toBeTruthy(); |
| 643 | expect(matchElement.children[1].firstChild.nodeValue).toEqual('me'); |
| 644 | |
| 645 | // not yet |
| 646 | expect(matchElement.children[0].children[1]).toBe(undefined); |
| 647 | |
| 648 | /* |
| 649 | var info = matchClass.create(matchElement).info(); |
| 650 | info.showTable(); |
| 651 | */ |
| 652 | var matchObj = matchClass.create(matchElement); |
| 653 | matchObj.open(); |
| 654 | |
| 655 | // Match |
| 656 | expect(matchElement.children[0].tagName).toEqual('DIV'); |
| 657 | |
| 658 | // snippet |
| 659 | expect(matchElement.children[0].children[0].tagName).toEqual('DIV'); |
| 660 | |
| 661 | expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy(); |
| 662 | |
| 663 | expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check'); |
| 664 | |
| 665 | // reference |
| 666 | |
| 667 | expect(matchElement.children[2].classList.contains('ref')).toBeTruthy(); |
| 668 | expect(matchElement.children[2].childNodes[1].nodeValue).toEqual('me'); |
| 669 | |
| 670 | // Add table |
| 671 | matchObj.panel.addTable(); |
| 672 | |
| 673 | // now |
| 674 | var infotable = matchElement.children[1]; |
| 675 | expect(infotable.tagName).toEqual('DIV'); |
| 676 | |
| 677 | expect(infotable.classList.contains('matchinfo')).toBeTruthy(); |
| 678 | |
| 679 | expect(infotable.firstChild.firstChild.firstChild.classList.contains('matchtable')).toBeTruthy(); |
| 680 | |
| 681 | // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy(); |
| 682 | }); |
| 683 | |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 684 | it('should parse into a table view with non-verbal elements (sync)', function () { |
| 685 | var matchElement = matchElementFactory(); |
| 686 | expect(matchElement.tagName).toEqual('LI'); |
| 687 | }); |
| 688 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 689 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 690 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 691 | describe('KorAP.RelationsView', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 692 | beforeAll(beforeAllFunc); |
| 693 | afterAll(afterAllFunc); |
| 694 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 695 | var tree; |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 696 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 697 | it('should be rendered async 1', function (done) { |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 698 | var matchObj = matchClass.create(match); |
| 699 | var relObj = relClass.create(matchObj); |
| 700 | expect(relObj).toBeTruthy(); |
| 701 | relObj.getData(undefined, undefined, "spans", function (y) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 702 | tree = y; |
| 703 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 704 | }); |
| 705 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 706 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 707 | it('should be rendered async 2', function () { |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 708 | expect(tree).toBeTruthy(); |
| 709 | expect(tree.nodes()).toEqual(49); |
| 710 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 711 | var e = tree.element(); |
| 712 | expect(e.nodeName).toEqual('svg'); |
| 713 | expect(e.getElementsByTagName('g').length).toEqual(48); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 714 | }); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 715 | |
| 716 | |
| 717 | it('should add a tree view async 2', function () { |
| 718 | var matchElement = matchElementFactory(); |
| 719 | var matchObj = matchClass.create(matchElement); |
| 720 | matchObj.open(); |
| 721 | matchObj.panel.addTree('mate', 'beebop', 'spans', function () { |
| 722 | done(); |
| 723 | }); |
| 724 | |
| 725 | // With added tree |
| 726 | var tree = matchElement.children[1].firstChild.firstChild.firstChild; |
| 727 | expect(tree.tagName).toEqual('DIV'); |
| 728 | expect(tree.classList.contains('matchtree')).toBeTruthy(); |
| 729 | expect(tree.children[0].tagName).toEqual('H6'); |
| 730 | expect(tree.children[0].children[0].tagName).toEqual('SPAN'); |
| 731 | expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate'); |
| 732 | expect(tree.children[0].children[1].tagName).toEqual('SPAN'); |
| 733 | expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop'); |
| 734 | |
| 735 | expect(tree.children[1].tagName).toEqual('DIV'); |
| 736 | }); |
| 737 | |
Akron | 3bdac53 | 2019-03-04 13:24:43 +0100 | [diff] [blame] | 738 | it('should make the tree downloadable', function () { |
| 739 | var treeClass = matchHierClass.create(treeSnippetHierarchy); |
| 740 | var treeElement = treeClass.element(); |
| 741 | expect(treeElement.tagName).toEqual("svg"); |
| 742 | |
| 743 | var base64 = treeClass.toBase64(); |
| 744 | var str = atob(base64); |
| 745 | expect(str).toMatch(new RegExp('<defs><style>path')); |
| 746 | expect(str).not.toMatch(new RegExp(' ')); |
| 747 | expect(str).toMatch(new RegExp('&')); |
| 748 | }); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 749 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 750 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 751 | |
| 752 | describe('KorAP.MatchTreeItem', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 753 | beforeAll(beforeAllFunc); |
| 754 | afterAll(afterAllFunc); |
| 755 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 756 | it('should be initializable', function () { |
| 757 | var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c']) |
| 758 | expect(mi.element().firstChild.nodeValue).toEqual('cnx/c'); |
| 759 | expect(mi.lcField()).toEqual(' cnx/c'); |
| 760 | expect(mi.foundry()).toEqual('cnx'); |
| 761 | expect(mi.layer()).toEqual('c'); |
| 762 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 763 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 764 | |
| 765 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 766 | describe('KorAP.MatchRelation', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 767 | beforeAll(beforeAllFunc); |
| 768 | afterAll(afterAllFunc); |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 769 | |
| 770 | var relExample = "<span class=\"context-left\"></span>" + |
| 771 | "<span class=\"match\">" + |
| 772 | " <span xml:id=\"token-GOE/AGA/01784-p199\">" + |
| 773 | " <span xlink:title=\"malt/d:ADV\" " + |
| 774 | " xlink:type=\"simple\" " + |
| 775 | " xlink:href=\"#token-GOE/AGA/01784-p199\">dann</span>" + |
| 776 | " </span>" + |
| 777 | " zog " + |
| 778 | " <span xlink:title=\"malt/d:SUBJ\" " + |
| 779 | " xlink:type=\"simple\" " + |
| 780 | " xlink:href=\"#token-GOE/AGA/01784-p199\">ich</span>" + |
| 781 | " <span xml:id=\"token-GOE/AGA/01784-p202\">" + |
| 782 | " <span xlink:title=\"malt/d:OBJA\" " + |
| 783 | " xlink:type=\"simple\" " + |
| 784 | " xlink:href=\"#token-GOE/AGA/01784-p199\">mich</span>" + |
| 785 | " </span>" + |
| 786 | "</span>" + |
| 787 | "<span class=\"context-right\"></span>"; |
| 788 | |
| 789 | |
| 790 | it('should be initializable', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 791 | var tree = matchRelClass.create(); |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 792 | expect(tree.size()).toBe(0); |
| 793 | }); |
| 794 | |
| 795 | it('should be parse string data', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 796 | var tree = matchRelClass.create(relExample); |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 797 | expect(tree.size()).toBe(4); |
| 798 | }); |
Akron | 0a785d4 | 2020-10-12 17:21:46 +0200 | [diff] [blame] | 799 | |
| 800 | it('should accept missing data', function () { |
| 801 | var relExample2 = "<span class=\"context-left\"><\/span>"+ |
| 802 | "<span class=\"match\">"+ |
| 803 | "{{"+ |
| 804 | "<span xml:id=\"token-WUD17\/D95\/09441-p180\">"+ |
| 805 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p179\">Wikiläum<\/span>"+ |
| 806 | "<\/span>"+ |
| 807 | "|"+ |
| 808 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p180\">Silber<\/span>"+ |
| 809 | "|"+ |
| 810 | "<span xlink:title=\"malt\/d:DET\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p183\">Dein<\/span>"+ |
| 811 | " "+ |
| 812 | "<span xml:id=\"token-WUD17\/D95\/09441-p183\">"+ |
| 813 | "<span xlink:title=\"malt\/d:ROOT\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p179-196\">Freund<\/span>"+ |
| 814 | "<\/span>"+ |
| 815 | " "+ |
| 816 | "<span xlink:title=\"malt\/d:DET\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p185\">der<\/span>"+ |
| 817 | " "+ |
| 818 | "<span xml:id=\"token-WUD17\/D95\/09441-p185-186\">"+ |
| 819 | "<span xml:id=\"token-WUD17\/D95\/09441-p185\">"+ |
| 820 | "<mark>"+ |
| 821 | "<span xlink:title=\"malt\/d:GMOD\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p183\">Baum<\/span>"+ |
| 822 | "<\/mark>"+ |
| 823 | "<\/span>"+ |
| 824 | "| "+ |
| 825 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p185-186\">09:38<\/span>"+ |
| 826 | "<\/span>"+ |
| 827 | ", "+ |
| 828 | "<span xlink:title=\"malt\/d:ATTR\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p188\">22.<\/span>"+ |
| 829 | " "+ |
| 830 | "<span xml:id=\"token-WUD17\/D95\/09441-p188\">"+ |
| 831 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p183\">Aug.<\/span>"+ |
| 832 | "<\/span>"+ |
| 833 | " "+ |
| 834 | "<span xml:id=\"token-WUD17\/D95\/09441-p189\">"+ |
| 835 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p188\">2015<\/span>"+ |
| 836 | "<\/span>"+ |
| 837 | " ("+ |
| 838 | "<span xlink:title=\"malt\/d:PAR\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p189\">CEST<\/span>"+ |
| 839 | ")"+ |
| 840 | "<\/span>"+ |
| 841 | "<span class=\"context-right\"><\/span>"; |
| 842 | var tree = matchRelClass.create(relExample2); |
| 843 | expect(tree.size()).toBe(18); |
| 844 | var treeElement = tree.element(); |
| 845 | expect(treeElement.tagName).toEqual("svg"); |
| 846 | tree.show(); |
| 847 | expect(treeElement.querySelector("text[text-anchor=\"middle\"]").textContent).toEqual("APP"); |
| 848 | }); |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 849 | }); |
| 850 | |
| 851 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 852 | describe('KorAP.MatchTreeMenu', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 853 | beforeAll(beforeAllFunc); |
| 854 | afterAll(afterAllFunc); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 855 | |
| 856 | it('should be initializable', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 857 | var menu = matchTreeMenuClass.create([ |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 858 | ['cnx/c', 'cnx', 'c'], |
| 859 | ['xip/c', 'xip', 'c'] |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 860 | ], matchTreeItemClass); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 861 | |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 862 | expect(menu.itemClass()).toEqual(matchTreeItemClass); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 863 | expect(menu.element().nodeName).toEqual('UL'); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 864 | expect(menu.element().classList.contains('visible')).toBeFalsy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 865 | expect(menu.limit()).toEqual(6); |
| 866 | menu.show(); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 867 | expect(menu.element().classList.contains('visible')).toBeTruthy(); |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 868 | expect(menu.item(0).active()).toBe(false); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 869 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 870 | }); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 871 | |
| 872 | //Test display and sorting of meta information |
| 873 | describe('KorAP.Meta', function(){ |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 874 | beforeAll(beforeAllFunc); |
| 875 | afterAll(afterAllFunc); |
| 876 | |
| 877 | var met = metaClass.create(match, fields); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 878 | var mel = met.element(); |
| 879 | |
| 880 | // Meta information should be parsed into a list |
| 881 | it('should parse in a meta view', function(){ |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 882 | expect(mel.tagName).toEqual('DL'); |
| 883 | expect(mel.children[0].tagName).toEqual('DIV'); |
| 884 | expect(mel.children[0].children[0].tagName).toEqual('DT'); |
| 885 | expect(mel.children[0].children[0].attributes[0].name).toEqual('title'); |
| 886 | expect(mel.children[0].children[1].tagName).toEqual('DD'); |
| 887 | expect(mel.children[0].children[1].getAttribute('data-type')).toEqual('type:text') |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 888 | |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 889 | expect(mel.children[0].children[0].firstChild.nodeValue).toEqual('author'); |
| 890 | expect(mel.children[0].children[1].firstChild.nodeValue).toEqual('Sprachpfleger, u.a.'); |
| 891 | expect(mel.children[0].children[0].attributes[0].value).toEqual('author'); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 892 | }); |
| 893 | |
| 894 | |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 895 | /* The keywords in the meta information list should be formatted to be able |
| 896 | to chose each keyword separately in the corpusByMatch assistant. */ |
| 897 | it('keywords should be formatted', function(){ |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 898 | |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 899 | //type:string or type:keyword should b not relevant |
| 900 | expect(mel.children[1].children[1].getAttribute('data-type')).toEqual('type:string') |
| 901 | expect(mel.children[1].children[1].classList.contains('metakeyvalues')).toBeTruthy; |
| 902 | expect(mel.children[1].children[1].children[0].tagName).toEqual('DIV'); |
| 903 | expect(mel.children[1].children[1].children[0].firstChild.nodeValue).toEqual('corenlp'); |
| 904 | expect(mel.children[1].children[1].children[1].tagName).toEqual('DIV'); |
| 905 | expect(mel.children[1].children[1].children[1].firstChild.nodeValue).toEqual('corenlp\/constituency'); |
| 906 | |
| 907 | expect(mel.children[2].children[1].classList.contains('metakeyvalues')).toBeTruthy; |
| 908 | expect(mel.children[2].children[1].children[0].tagName).toEqual('DIV'); |
| 909 | expect(mel.children[2].children[1].children[0].firstChild.nodeValue).toEqual('kultur'); |
| 910 | expect(mel.children[2].children[1].children[1].tagName).toEqual('DIV'); |
| 911 | expect(mel.children[2].children[1].children[1].firstChild.nodeValue).toEqual('film'); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 912 | }); |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 913 | |
| 914 | it('attachements should be formatted', function(){ |
Akron | 0f70076 | 2022-01-11 17:21:16 +0100 | [diff] [blame^] | 915 | //type:attachement with a link (legacy) |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 916 | expect(mel.children[3].children[1].getAttribute('data-type')).toEqual('type:attachement') |
Akron | 0f70076 | 2022-01-11 17:21:16 +0100 | [diff] [blame^] | 917 | expect(mel.children[3].children[1].classList.contains('metakeyvalues')).toBeFalsy; |
| 918 | expect(mel.children[3].children[0].firstChild.nodeValue).toEqual('xlink'); |
| 919 | expect(mel.children[3].children[1].firstChild.textContent).toEqual('Cool'); |
| 920 | expect(mel.children[3].children[1].firstChild.tagName).toEqual('A'); |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 921 | expect(mel.children[3].children[1].firstChild.getAttribute('href')).toEqual('https://de.wikipedia.org/wiki/Beispiel'); |
Akron | d3bb85b | 2019-02-08 10:15:13 +0100 | [diff] [blame] | 922 | |
Akron | 0f70076 | 2022-01-11 17:21:16 +0100 | [diff] [blame^] | 923 | //type:attachement with a link (uri encoded) |
Akron | d3bb85b | 2019-02-08 10:15:13 +0100 | [diff] [blame] | 924 | expect(mel.children[4].children[1].getAttribute('data-type')).toEqual('type:attachement') |
Akron | 0f70076 | 2022-01-11 17:21:16 +0100 | [diff] [blame^] | 925 | expect(mel.children[4].children[1].classList.contains('metakeyvalues')).toBeFalsy; |
| 926 | expect(mel.children[4].children[0].firstChild.nodeValue).toEqual('xlink2'); |
| 927 | expect(mel.children[4].children[1].firstChild.textContent).toEqual('Hallo!'); |
| 928 | expect(mel.children[4].children[1].firstChild.tagName).toEqual('A'); |
| 929 | expect(mel.children[4].children[1].firstChild.getAttribute('href')).toEqual('https://www.test.de'); |
| 930 | |
| 931 | //type:attachement with plain text |
| 932 | expect(mel.children[5].children[1].getAttribute('data-type')).toEqual('type:attachement') |
| 933 | expect(mel.children[5].children[1].classList.contains('metakeyvalues')).toBeFalsy; |
| 934 | expect(mel.children[5].children[0].firstChild.nodeValue).toEqual('z-reference'); |
| 935 | expect(mel.children[5].children[1].firstChild.nodeValue).toEqual('This is a reference'); |
Akron | d3bb85b | 2019-02-08 10:15:13 +0100 | [diff] [blame] | 936 | }); |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 937 | |
| 938 | |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 939 | |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 940 | // Meta information should be sorted alphabetically |
| 941 | it('should be alphabetically sorted', function(){ |
| 942 | var a = mel.children[0].children[0].firstChild.nodeValue; |
| 943 | var b = mel.children[1].children[0].firstChild.nodeValue; |
| 944 | var c = mel.children[2].children[0].firstChild.nodeValue; |
| 945 | expect(a.localeCompare(b)).toBe(-1); |
| 946 | expect(b.localeCompare(c)).toBe(-1); |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 947 | }); |
| 948 | |
| 949 | |
| 950 | it('should handle attachements', function () { |
| 951 | let uri = attachementClass.create("data:text/plain;title=new,Hallo"); |
| 952 | expect(uri.contentType).toEqual("text/plain"); |
| 953 | |
| 954 | expect(uri.payload).toEqual("Hallo"); |
| 955 | expect(uri.base64).toBeFalsy(); |
| 956 | expect(uri.isLink).toBeFalsy(); |
| 957 | expect(uri.param["title"]).toEqual("new"); |
| 958 | |
| 959 | uri = attachementClass.create("data:application/x.korap-link,https://de.wikipedia.org/wiki/Beispiel"); |
| 960 | expect(uri.contentType).toEqual("application/x.korap-link"); |
| 961 | expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel"); |
| 962 | expect(uri.base64).toBeFalsy(); |
| 963 | expect(uri.isLink).toBeTruthy(); |
| 964 | expect(uri.inline().textContent).toEqual("https://de.wikipedia.org/wiki/Beispiel"); |
| 965 | expect(uri.inline().nodeType).toEqual(1); |
| 966 | expect(uri.inline().tagName).toEqual("A"); |
| 967 | expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer"); |
| 968 | |
| 969 | |
| 970 | uri = attachementClass.create("data:application/x.korap-link;title=Das ist ein Titel,https://de.wikipedia.org/wiki/Beispiel"); |
| 971 | expect(uri.contentType).toEqual("application/x.korap-link"); |
| 972 | expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel"); |
| 973 | expect(uri.base64).toBeFalsy(); |
| 974 | expect(uri.isLink).toBeTruthy(); |
| 975 | expect(uri.inline().textContent).toEqual("Das ist ein Titel"); |
| 976 | expect(uri.inline().nodeType).toEqual(1); |
| 977 | expect(uri.inline().tagName).toEqual("A"); |
| 978 | expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer"); |
| 979 | |
| 980 | |
| 981 | uri = attachementClass.create("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D"); |
| 982 | expect(uri.contentType).toEqual("text/plain"); |
| 983 | expect(uri.payload).toEqual("Hello, World!"); |
| 984 | expect(uri.base64).toBeTruthy(); |
| 985 | expect(uri.isLink).toBeFalsy(); |
| 986 | expect(uri.inline().nodeType).toEqual(3); |
| 987 | expect(uri.inline().textContent).toEqual("Hello, World!"); |
| 988 | |
| 989 | uri = attachementClass.create("data:text/plain;title= new ; subTitle = old ;base64,SGVsbG8sIFdvcmxkIQ%3D%3D"); |
| 990 | expect(uri.contentType).toEqual("text/plain"); |
| 991 | expect(uri.payload).toEqual("Hello, World!"); |
| 992 | expect(uri.param["title"]).toEqual("new"); |
| 993 | expect(uri.param["subTitle"]).toEqual("old"); |
| 994 | expect(uri.base64).toBeTruthy(); |
| 995 | expect(uri.isLink).toBeFalsy(); |
| 996 | expect(uri.inline().nodeType).toEqual(3); |
| 997 | expect(uri.inline().textContent).toEqual("Hello, World!"); |
| 998 | }); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 999 | }); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 1000 | // table = view.toTable(); |
| 1001 | // table.sortBy(''); |
| 1002 | // table.element(); |
| 1003 | // tree = view.toTree(); |
| 1004 | // tree.element(); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 1005 | }); |