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 | e57e880 | 2020-10-17 08:23:45 +0200 | [diff] [blame^] | 454 | |
| 455 | it('should toggle', function () { |
| 456 | var e = matchElementFactory(); |
| 457 | |
| 458 | expect(e.classList.contains('active')).toBe(false); |
| 459 | expect(e["_match"]).toBe(undefined); |
| 460 | |
| 461 | var m = matchClass.create(e); |
| 462 | |
| 463 | expect(e.classList.contains('active')).toBe(false); |
| 464 | expect(e["_match"]).not.toBe(undefined); |
| 465 | |
| 466 | // Open the match |
| 467 | m.open(); |
| 468 | |
| 469 | expect(e.classList.contains('active')).toBe(true); |
| 470 | expect(e["_match"]).not.toBe(undefined); |
| 471 | |
| 472 | m.toggle(); |
| 473 | |
| 474 | expect(e.classList.contains('active')).toBe(false); |
| 475 | expect(e["_match"]).not.toBe(undefined); |
| 476 | |
| 477 | m.toggle(); |
| 478 | |
| 479 | expect(e.classList.contains('active')).toBe(true); |
| 480 | expect(e["_match"]).not.toBe(undefined); |
| 481 | }); |
| 482 | |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 483 | it('should open tree menu', function () { |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 484 | var e = matchElementFactory(); |
| 485 | var m = matchClass.create(e); |
| 486 | m.open(); |
Akron | bfe912c | 2018-07-17 19:30:52 +0200 | [diff] [blame] | 487 | 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] | 488 | expect(relation.getAttribute("class")).toEqual("tree"); |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 489 | expect(document.getElementsByClassName("button-group-list").length).toEqual(0); |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 490 | expect(document.activeElement.tagName).toEqual("BODY"); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 491 | |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 492 | // Show menu |
| 493 | relation.click(); |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 494 | expect(document.getElementsByClassName("button-group-list").length).toEqual(1); |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 495 | expect(document.activeElement.tagName).toEqual("UL"); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 496 | |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 497 | // Choose first tree |
Akron | 52ed22d | 2018-07-11 17:05:19 +0200 | [diff] [blame] | 498 | document.getElementsByClassName("button-group-list")[0].getElementsByTagName("li")[1].click(); |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 499 | expect(e.querySelector("div.matchinfo div.matchtree h6 span").innerText).toEqual("corenlp"); |
| 500 | |
| 501 | // This should blur the focus |
| 502 | expect(document.activeElement.tagName).toEqual("BODY"); |
hebasta | 87f1b1f | 2019-07-30 13:03:23 +0200 | [diff] [blame] | 503 | |
Akron | c296ca2 | 2018-04-24 16:35:26 +0200 | [diff] [blame] | 504 | }); |
| 505 | |
| 506 | }); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 507 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 508 | describe('KorAP.TableView', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 509 | beforeAll(beforeAllFunc); |
| 510 | afterAll(afterAllFunc); |
Akron | 5dc3117 | 2019-05-15 18:43:48 +0200 | [diff] [blame] | 511 | |
| 512 | let longString = " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können."; |
| 513 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 514 | var table; |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 515 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 516 | var matchObj = matchClass.create(match); |
| 517 | var tableObj = tableClass.create(matchObj); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 518 | |
| 519 | var table1, table2; |
| 520 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 521 | it('should fail to load a table async', function (done) { |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 522 | expect(tableObj).toBeTruthy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 523 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 524 | tableObj.getData([], function (tablen) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 525 | table1 = tablen; |
| 526 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 527 | }); |
| 528 | }); |
| 529 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 530 | |
Akron | aeeb825 | 2018-09-19 18:51:00 +0200 | [diff] [blame] | 531 | xit('should\'nt be parsable (async)', function () { |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 532 | expect(table1).not.toBeTruthy(); |
| 533 | }); |
| 534 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 535 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 536 | it('should be retrieved async', function (done) { |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 537 | expect(tableObj).toBeTruthy(); |
| 538 | tableObj.getData(undefined, function (x) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 539 | table = x; |
| 540 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 541 | }); |
| 542 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 543 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 544 | it('should parse into a table (async)', function () { |
| 545 | expect(table).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame] | 546 | |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 547 | expect(table.length()).toBe(8); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 548 | |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 549 | expect(table.getToken(0)).toBe(""); |
| 550 | expect(table.getToken(1)).toBe("Außerdem "); |
| 551 | expect(table.getToken(2)).toBe("meist"); |
| 552 | expect(table.getToken(3)).toBe("deutlich"); |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 553 | expect(table.getToken(5)).toBe("leistungsfähiger"); |
| 554 | expect(table.getToken(6)).toBe(longString); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 555 | |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 556 | expect(table.getValue(2, "cnx", "p")[0]).toBe("ADV"); |
| 557 | expect(table.getValue(2, "cnx", "syn")[0]).toBe("@PREMOD"); |
| 558 | expect(table.getValue(2, "mate", "l")[0]).toBe("meist"); |
| 559 | expect(table.getValue(2, "mate", "l")[1]).toBeUndefined(); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 560 | |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 561 | expect(table.getValue(5, "cnx", "l")[0]).toBe("fähig"); |
| 562 | expect(table.getValue(5, "cnx", "l")[1]).toBe("leistung"); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 563 | }); |
| 564 | |
| 565 | it('should be rendered async', function () { |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame] | 566 | var e = table.element().firstChild; |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 567 | expect(e.nodeName).toBe('TABLE'); |
| 568 | expect(e.children[0].nodeName).toBe('THEAD'); |
| 569 | var tr = e.children[0].children[0]; |
| 570 | expect(tr.nodeName).toBe('TR'); |
| 571 | expect(tr.children[0].nodeName).toBe('TH'); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 572 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 573 | expect(tr.children[0].firstChild.nodeValue).toBe('Foundry'); |
| 574 | expect(tr.children[1].firstChild.nodeValue).toBe('Layer'); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 575 | |
| 576 | expect(tr.children[2].classList.contains('cutted')).toBeTruthy(); |
| 577 | expect(tr.children[3].firstChild.nodeValue).toBe('Außerdem '); |
| 578 | |
| 579 | |
| 580 | expect(tr.children[4].firstChild.nodeValue).toBe('meist'); |
Akron | ad1e46a | 2018-09-19 15:55:40 +0200 | [diff] [blame] | 581 | expect(tr.children[4].classList.contains('mark')).toBeFalsy(); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 582 | expect(tr.children[5].firstChild.nodeValue).toBe('deutlich'); |
| 583 | expect(tr.children[5].classList.contains('mark')).toBeTruthy(); |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 584 | expect(tr.children[6].firstChild.nodeValue).toBe('▮'); |
| 585 | expect(tr.children[7].firstChild.nodeValue).toBe('leistungsfähiger'); |
| 586 | expect(tr.children[7].classList.contains('mark')).toBeFalsy(); |
| 587 | expect(tr.children[7].hasAttribute("title")).toBeFalsy(); |
| 588 | expect(tr.children[8].firstChild.nodeValue).toBe(longString); |
| 589 | expect(tr.children[8].getAttribute("title")).toBe(longString); |
| 590 | expect(tr.children[9].classList.contains('cutted')).toBeTruthy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 591 | |
| 592 | // first row |
| 593 | tr = e.children[1].children[0]; |
| 594 | expect(tr.nodeName).toBe('TR'); |
| 595 | expect(tr.getAttribute('tabindex')).toEqual('0'); |
| 596 | expect(tr.children[0].nodeName).toBe('TH'); |
| 597 | expect(tr.children[0].firstChild.nodeValue).toEqual('cnx'); |
| 598 | expect(tr.children[1].firstChild.nodeValue).toEqual('l'); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 599 | expect(tr.children[4].firstChild.nodeValue).toEqual('meist'); |
| 600 | expect(tr.children[5].firstChild.nodeValue).toEqual('deutlich'); |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 601 | expect(tr.children[6].firstChild).toBeNull(); |
| 602 | expect(tr.children[7].firstChild.firstChild.nodeValue).toEqual('fähig'); |
| 603 | expect(tr.children[7].lastChild.firstChild.nodeValue).toEqual('leistung'); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 604 | |
| 605 | // second row |
| 606 | tr = e.children[1].children[1]; |
| 607 | expect(tr.nodeName).toBe('TR'); |
| 608 | expect(tr.getAttribute('tabindex')).toEqual('0'); |
| 609 | expect(tr.children[0].nodeName).toBe('TH'); |
| 610 | expect(tr.children[0].firstChild.nodeValue).toEqual('cnx'); |
| 611 | expect(tr.children[1].firstChild.nodeValue).toEqual('p'); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 612 | expect(tr.children[4].firstChild.nodeValue).toEqual('ADV'); |
| 613 | expect(tr.children[5].firstChild.nodeValue).toEqual('A'); |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 614 | expect(tr.children[6].firstChild).toBeNull(); |
| 615 | expect(tr.children[7].firstChild.firstChild.nodeValue).toEqual('A'); |
| 616 | expect(tr.children[7].lastChild.firstChild.nodeValue).toEqual('ADJA'); |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 617 | |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 618 | expect(tr.children[7].firstChild.getAttribute("title")).toEqual('Adjective'); |
Akron | 1a780fe | 2019-05-21 15:59:00 +0200 | [diff] [blame] | 619 | expect(tr.children[4].getAttribute("title")).toEqual('Adverb'); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 620 | }); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 621 | |
| 622 | |
| 623 | it('should parse into a table view (sync)', function () { |
| 624 | var matchElement = matchElementFactory(); |
| 625 | expect(matchElement.tagName).toEqual('LI'); |
| 626 | |
| 627 | // Match |
| 628 | expect(matchElement.children[0].tagName).toEqual('DIV'); |
| 629 | |
| 630 | // snippet |
| 631 | expect(matchElement.children[0].children[0].tagName).toEqual('DIV'); |
| 632 | expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy(); |
| 633 | expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check'); |
| 634 | |
| 635 | // reference |
| 636 | expect(matchElement.children[1].classList.contains('ref')).toBeTruthy(); |
| 637 | expect(matchElement.children[1].firstChild.nodeValue).toEqual('me'); |
| 638 | |
| 639 | // not yet |
| 640 | expect(matchElement.children[0].children[1]).toBe(undefined); |
| 641 | |
| 642 | /* |
| 643 | var info = matchClass.create(matchElement).info(); |
| 644 | info.showTable(); |
| 645 | */ |
| 646 | var matchObj = matchClass.create(matchElement); |
| 647 | matchObj.open(); |
| 648 | |
| 649 | // Match |
| 650 | expect(matchElement.children[0].tagName).toEqual('DIV'); |
| 651 | |
| 652 | // snippet |
| 653 | expect(matchElement.children[0].children[0].tagName).toEqual('DIV'); |
| 654 | |
| 655 | expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy(); |
| 656 | |
| 657 | expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check'); |
| 658 | |
| 659 | // reference |
| 660 | |
| 661 | expect(matchElement.children[2].classList.contains('ref')).toBeTruthy(); |
| 662 | expect(matchElement.children[2].childNodes[1].nodeValue).toEqual('me'); |
| 663 | |
| 664 | // Add table |
| 665 | matchObj.panel.addTable(); |
| 666 | |
| 667 | // now |
| 668 | var infotable = matchElement.children[1]; |
| 669 | expect(infotable.tagName).toEqual('DIV'); |
| 670 | |
| 671 | expect(infotable.classList.contains('matchinfo')).toBeTruthy(); |
| 672 | |
| 673 | expect(infotable.firstChild.firstChild.firstChild.classList.contains('matchtable')).toBeTruthy(); |
| 674 | |
| 675 | // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy(); |
| 676 | }); |
| 677 | |
Akron | 158fce1 | 2019-12-17 14:43:29 +0100 | [diff] [blame] | 678 | it('should parse into a table view with non-verbal elements (sync)', function () { |
| 679 | var matchElement = matchElementFactory(); |
| 680 | expect(matchElement.tagName).toEqual('LI'); |
| 681 | }); |
| 682 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 683 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 684 | |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 685 | describe('KorAP.RelationsView', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 686 | beforeAll(beforeAllFunc); |
| 687 | afterAll(afterAllFunc); |
| 688 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 689 | var tree; |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 690 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 691 | it('should be rendered async 1', function (done) { |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 692 | var matchObj = matchClass.create(match); |
| 693 | var relObj = relClass.create(matchObj); |
| 694 | expect(relObj).toBeTruthy(); |
| 695 | relObj.getData(undefined, undefined, "spans", function (y) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 696 | tree = y; |
| 697 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 698 | }); |
| 699 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 700 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 701 | it('should be rendered async 2', function () { |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 702 | expect(tree).toBeTruthy(); |
| 703 | expect(tree.nodes()).toEqual(49); |
| 704 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 705 | var e = tree.element(); |
| 706 | expect(e.nodeName).toEqual('svg'); |
| 707 | expect(e.getElementsByTagName('g').length).toEqual(48); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 708 | }); |
Akron | 7f9a6a3 | 2018-07-18 15:05:23 +0200 | [diff] [blame] | 709 | |
| 710 | |
| 711 | it('should add a tree view async 2', function () { |
| 712 | var matchElement = matchElementFactory(); |
| 713 | var matchObj = matchClass.create(matchElement); |
| 714 | matchObj.open(); |
| 715 | matchObj.panel.addTree('mate', 'beebop', 'spans', function () { |
| 716 | done(); |
| 717 | }); |
| 718 | |
| 719 | // With added tree |
| 720 | var tree = matchElement.children[1].firstChild.firstChild.firstChild; |
| 721 | expect(tree.tagName).toEqual('DIV'); |
| 722 | expect(tree.classList.contains('matchtree')).toBeTruthy(); |
| 723 | expect(tree.children[0].tagName).toEqual('H6'); |
| 724 | expect(tree.children[0].children[0].tagName).toEqual('SPAN'); |
| 725 | expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate'); |
| 726 | expect(tree.children[0].children[1].tagName).toEqual('SPAN'); |
| 727 | expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop'); |
| 728 | |
| 729 | expect(tree.children[1].tagName).toEqual('DIV'); |
| 730 | }); |
| 731 | |
Akron | 3bdac53 | 2019-03-04 13:24:43 +0100 | [diff] [blame] | 732 | it('should make the tree downloadable', function () { |
| 733 | var treeClass = matchHierClass.create(treeSnippetHierarchy); |
| 734 | var treeElement = treeClass.element(); |
| 735 | expect(treeElement.tagName).toEqual("svg"); |
| 736 | |
| 737 | var base64 = treeClass.toBase64(); |
| 738 | var str = atob(base64); |
| 739 | expect(str).toMatch(new RegExp('<defs><style>path')); |
| 740 | expect(str).not.toMatch(new RegExp(' ')); |
| 741 | expect(str).toMatch(new RegExp('&')); |
| 742 | }); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 743 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 744 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 745 | |
| 746 | describe('KorAP.MatchTreeItem', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 747 | beforeAll(beforeAllFunc); |
| 748 | afterAll(afterAllFunc); |
| 749 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 750 | it('should be initializable', function () { |
| 751 | var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c']) |
| 752 | expect(mi.element().firstChild.nodeValue).toEqual('cnx/c'); |
| 753 | expect(mi.lcField()).toEqual(' cnx/c'); |
| 754 | expect(mi.foundry()).toEqual('cnx'); |
| 755 | expect(mi.layer()).toEqual('c'); |
| 756 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 757 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 758 | |
| 759 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 760 | describe('KorAP.MatchRelation', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 761 | beforeAll(beforeAllFunc); |
| 762 | afterAll(afterAllFunc); |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 763 | |
| 764 | var relExample = "<span class=\"context-left\"></span>" + |
| 765 | "<span class=\"match\">" + |
| 766 | " <span xml:id=\"token-GOE/AGA/01784-p199\">" + |
| 767 | " <span xlink:title=\"malt/d:ADV\" " + |
| 768 | " xlink:type=\"simple\" " + |
| 769 | " xlink:href=\"#token-GOE/AGA/01784-p199\">dann</span>" + |
| 770 | " </span>" + |
| 771 | " zog " + |
| 772 | " <span xlink:title=\"malt/d:SUBJ\" " + |
| 773 | " xlink:type=\"simple\" " + |
| 774 | " xlink:href=\"#token-GOE/AGA/01784-p199\">ich</span>" + |
| 775 | " <span xml:id=\"token-GOE/AGA/01784-p202\">" + |
| 776 | " <span xlink:title=\"malt/d:OBJA\" " + |
| 777 | " xlink:type=\"simple\" " + |
| 778 | " xlink:href=\"#token-GOE/AGA/01784-p199\">mich</span>" + |
| 779 | " </span>" + |
| 780 | "</span>" + |
| 781 | "<span class=\"context-right\"></span>"; |
| 782 | |
| 783 | |
| 784 | it('should be initializable', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 785 | var tree = matchRelClass.create(); |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 786 | expect(tree.size()).toBe(0); |
| 787 | }); |
| 788 | |
| 789 | it('should be parse string data', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 790 | var tree = matchRelClass.create(relExample); |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 791 | expect(tree.size()).toBe(4); |
| 792 | }); |
Akron | 0a785d4 | 2020-10-12 17:21:46 +0200 | [diff] [blame] | 793 | |
| 794 | it('should accept missing data', function () { |
| 795 | var relExample2 = "<span class=\"context-left\"><\/span>"+ |
| 796 | "<span class=\"match\">"+ |
| 797 | "{{"+ |
| 798 | "<span xml:id=\"token-WUD17\/D95\/09441-p180\">"+ |
| 799 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p179\">Wikiläum<\/span>"+ |
| 800 | "<\/span>"+ |
| 801 | "|"+ |
| 802 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p180\">Silber<\/span>"+ |
| 803 | "|"+ |
| 804 | "<span xlink:title=\"malt\/d:DET\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p183\">Dein<\/span>"+ |
| 805 | " "+ |
| 806 | "<span xml:id=\"token-WUD17\/D95\/09441-p183\">"+ |
| 807 | "<span xlink:title=\"malt\/d:ROOT\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p179-196\">Freund<\/span>"+ |
| 808 | "<\/span>"+ |
| 809 | " "+ |
| 810 | "<span xlink:title=\"malt\/d:DET\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p185\">der<\/span>"+ |
| 811 | " "+ |
| 812 | "<span xml:id=\"token-WUD17\/D95\/09441-p185-186\">"+ |
| 813 | "<span xml:id=\"token-WUD17\/D95\/09441-p185\">"+ |
| 814 | "<mark>"+ |
| 815 | "<span xlink:title=\"malt\/d:GMOD\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p183\">Baum<\/span>"+ |
| 816 | "<\/mark>"+ |
| 817 | "<\/span>"+ |
| 818 | "| "+ |
| 819 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p185-186\">09:38<\/span>"+ |
| 820 | "<\/span>"+ |
| 821 | ", "+ |
| 822 | "<span xlink:title=\"malt\/d:ATTR\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p188\">22.<\/span>"+ |
| 823 | " "+ |
| 824 | "<span xml:id=\"token-WUD17\/D95\/09441-p188\">"+ |
| 825 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p183\">Aug.<\/span>"+ |
| 826 | "<\/span>"+ |
| 827 | " "+ |
| 828 | "<span xml:id=\"token-WUD17\/D95\/09441-p189\">"+ |
| 829 | "<span xlink:title=\"malt\/d:APP\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p188\">2015<\/span>"+ |
| 830 | "<\/span>"+ |
| 831 | " ("+ |
| 832 | "<span xlink:title=\"malt\/d:PAR\" xlink:show=\"none\" xlink:href=\"#token-WUD17\/D95\/09441-p189\">CEST<\/span>"+ |
| 833 | ")"+ |
| 834 | "<\/span>"+ |
| 835 | "<span class=\"context-right\"><\/span>"; |
| 836 | var tree = matchRelClass.create(relExample2); |
| 837 | expect(tree.size()).toBe(18); |
| 838 | var treeElement = tree.element(); |
| 839 | expect(treeElement.tagName).toEqual("svg"); |
| 840 | tree.show(); |
| 841 | expect(treeElement.querySelector("text[text-anchor=\"middle\"]").textContent).toEqual("APP"); |
| 842 | }); |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 843 | }); |
| 844 | |
| 845 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 846 | describe('KorAP.MatchTreeMenu', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 847 | beforeAll(beforeAllFunc); |
| 848 | afterAll(afterAllFunc); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 849 | |
| 850 | it('should be initializable', function () { |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 851 | var menu = matchTreeMenuClass.create([ |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 852 | ['cnx/c', 'cnx', 'c'], |
| 853 | ['xip/c', 'xip', 'c'] |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 854 | ], matchTreeItemClass); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 855 | |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 856 | expect(menu.itemClass()).toEqual(matchTreeItemClass); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 857 | expect(menu.element().nodeName).toEqual('UL'); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 858 | expect(menu.element().classList.contains('visible')).toBeFalsy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 859 | expect(menu.limit()).toEqual(6); |
| 860 | menu.show(); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 861 | expect(menu.element().classList.contains('visible')).toBeTruthy(); |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 862 | expect(menu.item(0).active()).toBe(false); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 863 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 864 | }); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 865 | |
| 866 | //Test display and sorting of meta information |
| 867 | describe('KorAP.Meta', function(){ |
Akron | d8692de | 2018-07-26 13:06:01 +0200 | [diff] [blame] | 868 | beforeAll(beforeAllFunc); |
| 869 | afterAll(afterAllFunc); |
| 870 | |
| 871 | var met = metaClass.create(match, fields); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 872 | var mel = met.element(); |
| 873 | |
| 874 | // Meta information should be parsed into a list |
| 875 | it('should parse in a meta view', function(){ |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 876 | expect(mel.tagName).toEqual('DL'); |
| 877 | expect(mel.children[0].tagName).toEqual('DIV'); |
| 878 | expect(mel.children[0].children[0].tagName).toEqual('DT'); |
| 879 | expect(mel.children[0].children[0].attributes[0].name).toEqual('title'); |
| 880 | expect(mel.children[0].children[1].tagName).toEqual('DD'); |
| 881 | expect(mel.children[0].children[1].getAttribute('data-type')).toEqual('type:text') |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 882 | |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 883 | expect(mel.children[0].children[0].firstChild.nodeValue).toEqual('author'); |
| 884 | expect(mel.children[0].children[1].firstChild.nodeValue).toEqual('Sprachpfleger, u.a.'); |
| 885 | expect(mel.children[0].children[0].attributes[0].value).toEqual('author'); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 886 | }); |
| 887 | |
| 888 | |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 889 | /* The keywords in the meta information list should be formatted to be able |
| 890 | to chose each keyword separately in the corpusByMatch assistant. */ |
| 891 | it('keywords should be formatted', function(){ |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 892 | |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 893 | //type:string or type:keyword should b not relevant |
| 894 | expect(mel.children[1].children[1].getAttribute('data-type')).toEqual('type:string') |
| 895 | expect(mel.children[1].children[1].classList.contains('metakeyvalues')).toBeTruthy; |
| 896 | expect(mel.children[1].children[1].children[0].tagName).toEqual('DIV'); |
| 897 | expect(mel.children[1].children[1].children[0].firstChild.nodeValue).toEqual('corenlp'); |
| 898 | expect(mel.children[1].children[1].children[1].tagName).toEqual('DIV'); |
| 899 | expect(mel.children[1].children[1].children[1].firstChild.nodeValue).toEqual('corenlp\/constituency'); |
| 900 | |
| 901 | expect(mel.children[2].children[1].classList.contains('metakeyvalues')).toBeTruthy; |
| 902 | expect(mel.children[2].children[1].children[0].tagName).toEqual('DIV'); |
| 903 | expect(mel.children[2].children[1].children[0].firstChild.nodeValue).toEqual('kultur'); |
| 904 | expect(mel.children[2].children[1].children[1].tagName).toEqual('DIV'); |
| 905 | expect(mel.children[2].children[1].children[1].firstChild.nodeValue).toEqual('film'); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 906 | }); |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 907 | |
| 908 | it('attachements should be formatted', function(){ |
Akron | d3bb85b | 2019-02-08 10:15:13 +0100 | [diff] [blame] | 909 | //type:attachement with a link |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 910 | expect(mel.children[3].children[1].getAttribute('data-type')).toEqual('type:attachement') |
| 911 | expect(mel.children[3].children[1].classList.contains('metakeyvalues')).toBeFalsy; |
| 912 | expect(mel.children[3].children[0].firstChild.nodeValue).toEqual('xlink'); |
| 913 | expect(mel.children[3].children[1].firstChild.textContent).toEqual('Cool'); |
| 914 | expect(mel.children[3].children[1].firstChild.tagName).toEqual('A'); |
| 915 | 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] | 916 | |
| 917 | //type:attachement with plain text |
| 918 | expect(mel.children[4].children[1].getAttribute('data-type')).toEqual('type:attachement') |
| 919 | expect(mel.children[4].children[1].classList.contains('metakeyvalues')).toBeFalsy; |
| 920 | expect(mel.children[4].children[0].firstChild.nodeValue).toEqual('z-reference'); |
| 921 | expect(mel.children[4].children[1].firstChild.nodeValue).toEqual('This is a reference'); |
| 922 | }); |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 923 | |
| 924 | |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 925 | |
Akron | fa32c9d | 2018-11-20 15:39:18 +0100 | [diff] [blame] | 926 | // Meta information should be sorted alphabetically |
| 927 | it('should be alphabetically sorted', function(){ |
| 928 | var a = mel.children[0].children[0].firstChild.nodeValue; |
| 929 | var b = mel.children[1].children[0].firstChild.nodeValue; |
| 930 | var c = mel.children[2].children[0].firstChild.nodeValue; |
| 931 | expect(a.localeCompare(b)).toBe(-1); |
| 932 | expect(b.localeCompare(c)).toBe(-1); |
Akron | a0ea3c3 | 2018-12-14 18:33:48 +0100 | [diff] [blame] | 933 | }); |
| 934 | |
| 935 | |
| 936 | it('should handle attachements', function () { |
| 937 | let uri = attachementClass.create("data:text/plain;title=new,Hallo"); |
| 938 | expect(uri.contentType).toEqual("text/plain"); |
| 939 | |
| 940 | expect(uri.payload).toEqual("Hallo"); |
| 941 | expect(uri.base64).toBeFalsy(); |
| 942 | expect(uri.isLink).toBeFalsy(); |
| 943 | expect(uri.param["title"]).toEqual("new"); |
| 944 | |
| 945 | uri = attachementClass.create("data:application/x.korap-link,https://de.wikipedia.org/wiki/Beispiel"); |
| 946 | expect(uri.contentType).toEqual("application/x.korap-link"); |
| 947 | expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel"); |
| 948 | expect(uri.base64).toBeFalsy(); |
| 949 | expect(uri.isLink).toBeTruthy(); |
| 950 | expect(uri.inline().textContent).toEqual("https://de.wikipedia.org/wiki/Beispiel"); |
| 951 | expect(uri.inline().nodeType).toEqual(1); |
| 952 | expect(uri.inline().tagName).toEqual("A"); |
| 953 | expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer"); |
| 954 | |
| 955 | |
| 956 | uri = attachementClass.create("data:application/x.korap-link;title=Das ist ein Titel,https://de.wikipedia.org/wiki/Beispiel"); |
| 957 | expect(uri.contentType).toEqual("application/x.korap-link"); |
| 958 | expect(uri.payload).toEqual("https://de.wikipedia.org/wiki/Beispiel"); |
| 959 | expect(uri.base64).toBeFalsy(); |
| 960 | expect(uri.isLink).toBeTruthy(); |
| 961 | expect(uri.inline().textContent).toEqual("Das ist ein Titel"); |
| 962 | expect(uri.inline().nodeType).toEqual(1); |
| 963 | expect(uri.inline().tagName).toEqual("A"); |
| 964 | expect(uri.inline().getAttribute("rel")).toEqual("noopener noreferrer"); |
| 965 | |
| 966 | |
| 967 | uri = attachementClass.create("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D"); |
| 968 | expect(uri.contentType).toEqual("text/plain"); |
| 969 | expect(uri.payload).toEqual("Hello, World!"); |
| 970 | expect(uri.base64).toBeTruthy(); |
| 971 | expect(uri.isLink).toBeFalsy(); |
| 972 | expect(uri.inline().nodeType).toEqual(3); |
| 973 | expect(uri.inline().textContent).toEqual("Hello, World!"); |
| 974 | |
| 975 | uri = attachementClass.create("data:text/plain;title= new ; subTitle = old ;base64,SGVsbG8sIFdvcmxkIQ%3D%3D"); |
| 976 | expect(uri.contentType).toEqual("text/plain"); |
| 977 | expect(uri.payload).toEqual("Hello, World!"); |
| 978 | expect(uri.param["title"]).toEqual("new"); |
| 979 | expect(uri.param["subTitle"]).toEqual("old"); |
| 980 | expect(uri.base64).toBeTruthy(); |
| 981 | expect(uri.isLink).toBeFalsy(); |
| 982 | expect(uri.inline().nodeType).toEqual(3); |
| 983 | expect(uri.inline().textContent).toEqual("Hello, World!"); |
| 984 | }); |
hebasta | 999d6c1 | 2018-04-23 12:44:59 +0200 | [diff] [blame] | 985 | }); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 986 | // table = view.toTable(); |
| 987 | // table.sortBy(''); |
| 988 | // table.element(); |
| 989 | // tree = view.toTree(); |
| 990 | // tree.element(); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 991 | }); |