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