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