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 |
| 3 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 4 | var available = [ |
| 5 | 'base/s=spans', |
| 6 | 'corenlp/c=spans', |
| 7 | 'corenlp/ne=tokens', |
| 8 | 'corenlp/p=tokens', |
| 9 | 'corenlp/s=spans', |
| 10 | 'glemm/l=tokens', |
| 11 | 'mate/l=tokens', |
| 12 | 'mate/m=tokens', |
| 13 | 'mate/p=tokens', |
| 14 | 'opennlp/p=tokens', |
| 15 | 'opennlp/s=spans', |
| 16 | 'tt/l=tokens', |
| 17 | 'tt/p=tokens', |
| 18 | 'tt/s=spans' |
| 19 | ]; |
| 20 | |
| 21 | var match = { |
| 22 | 'corpusID' : 'WPD', |
| 23 | 'docID' : 'UUU', |
| 24 | 'textID' : '01912', |
| 25 | 'matchID' : 'p121-122', |
Akron | 0a6768f | 2016-07-13 18:00:43 +0200 | [diff] [blame] | 26 | 'textSigle' : 'WPD/UUU/01912', |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 27 | 'available' : available |
| 28 | }; |
| 29 | |
| 30 | var snippet = "<span title=\"cnx/l:meist\">" + |
Akron | 4e47d0b | 2017-07-03 17:58:37 +0200 | [diff] [blame] | 31 | " <span title=\"cnx/p:ADV\">" + |
| 32 | " <span title=\"cnx/syn:@PREMOD\">" + |
| 33 | " <span title=\"mate/l:meist\">" + |
| 34 | " <span title=\"mate/l:meist\">" + |
| 35 | " <span title=\"mate/p:ADV\">" + |
| 36 | " <span title=\"opennlp/p:ADV\">meist</span>" + |
| 37 | " </span>" + |
| 38 | " </span>" + |
| 39 | " </span>" + |
| 40 | " </span>" + |
| 41 | " </span>" + |
| 42 | "</span>" + |
| 43 | "<span title=\"cnx/l:deutlich\">" + |
| 44 | " <span title=\"cnx/p:A\">" + |
| 45 | " <span title=\"cnx/syn:@PREMOD\">" + |
| 46 | " <span title=\"mate/l:deutlich\">" + |
| 47 | " <span title=\"mate/m:degree:pos\">" + |
| 48 | " <span title=\"mate/p:ADJD\">" + |
| 49 | " <span title=\"opennlp/p:ADJD\">deutlich</span>" + |
| 50 | " </span>" + |
| 51 | " </span>" + |
| 52 | " </span>" + |
| 53 | " </span>" + |
| 54 | " </span>" + |
| 55 | "</span>" + |
| 56 | "<span title=\"cnx/l:fähig\">" + |
| 57 | " <span title=\"cnx/l:leistung\">" + |
| 58 | " <span title=\"cnx/p:A\">" + |
| 59 | " <span title=\"cnx/p:ADJA\">" + |
| 60 | " <span title=\"cnx/syn:@NH\">" + |
| 61 | " <span title=\"mate/l:leistungsfähig\">" + |
| 62 | " <span title=\"mate/m:degree:comp\">" + |
| 63 | " <span title=\"mate/p:ADJD\">" + |
| 64 | " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" + |
| 65 | " </span>" + |
| 66 | " </span>" + |
| 67 | " </span>" + |
| 68 | " </span>" + |
| 69 | " </span>" + |
| 70 | " </span>" + |
| 71 | " </span>" + |
| 72 | "</span>"; |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 73 | |
| 74 | var treeSnippet = |
| 75 | "<span class=\"context-left\"></span>" + |
| 76 | "<span class=\"match\">" + |
| 77 | " <span title=\"xip/c:MC\">" + |
| 78 | " <span title=\"xip/c:TOP\">" + |
| 79 | " <span title=\"xip/c:PP\">" + |
| 80 | " <span title=\"xip/c:PREP\">Mit</span>" + |
| 81 | " <span title=\"xip/c:NP\">" + |
| 82 | " <span title=\"xip/c:DET\">dieser</span>" + |
| 83 | " <span title=\"xip/c:NPA\">" + |
| 84 | " <span title=\"xip/c:NOUN\">Methode</span>" + |
| 85 | " </span>" + |
| 86 | " </span>" + |
| 87 | " </span>" + |
| 88 | " <span title=\"xip/c:VERB\">ist</span>" + |
Akron | 98a933f | 2016-08-11 00:19:17 +0200 | [diff] [blame] | 89 | " <mark>" + |
| 90 | " <span title=\"xip/c:NP\">" + |
| 91 | " <span title=\"xip/c:PRON\">es</span>" + |
| 92 | " </span>" + |
| 93 | " <span title=\"xip/c:AP\">" + |
| 94 | " <span title=\"xip/c:ADV\">nun</span>" + |
| 95 | " <span title=\"xip/c:ADJ\">möglich</span>" + |
| 96 | " </span>" + |
| 97 | " </mark>" + |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 98 | " <span title=\"xip/c:ADV\">z. B.</span>" + |
| 99 | " <span title=\"xip/c:NPA\">" + |
| 100 | " <span title=\"xip/c:NP\">" + |
| 101 | " <span title=\"xip/c:NOUN\">Voice</span>" + |
| 102 | " </span>" + |
| 103 | " </span>" + "(" + |
| 104 | " <span title=\"xip/c:INS\">" + |
| 105 | " <span title=\"xip/c:NPA\">" + |
| 106 | " <span title=\"xip/c:NP\">" + |
| 107 | " <span title=\"xip/c:NOUN\">Sprache</span>" + |
| 108 | " </span>" + |
| 109 | " </span>" + |
| 110 | " </span>" + ")" + |
| 111 | " <span title=\"xip/c:VERB\">bevorzugt</span>" + |
| 112 | " <span title=\"xip/c:PP\">" + |
| 113 | " <span title=\"xip/c:PREP\">in</span>" + |
| 114 | " <span title=\"xip/c:NP\">" + |
| 115 | " <span title=\"xip/c:PRON\">der</span>" + |
| 116 | " </span>" + |
| 117 | " <span title=\"xip/c:NPA\">" + |
| 118 | " <span title=\"xip/c:NP\">" + |
| 119 | " <span title=\"xip/c:NOUN\">Bridge</span>" + |
| 120 | " </span>" + |
| 121 | " </span>" + |
| 122 | " </span>" + |
| 123 | " <span title=\"xip/c:INFC\">" + |
| 124 | " <span title=\"xip/c:INS\">" + |
| 125 | " <span title=\"xip/c:VERB\">weiterzugeben</span>" + |
| 126 | " </span>" + |
| 127 | " </span>" + |
| 128 | " </span>" + |
| 129 | " </span>" + |
| 130 | "</span>" + |
| 131 | "<span class=\"context-right\"></span>"; |
| 132 | |
| 133 | |
| 134 | function matchElementFactory () { |
| 135 | var me = document.createElement('li'); |
| 136 | |
| 137 | me.setAttribute( |
| 138 | 'data-available-info', |
| 139 | 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' + |
| 140 | ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' + |
| 141 | ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' + |
| 142 | ' tt/p=tokens tt/s=spans'); |
| 143 | |
| 144 | me.setAttribute('data-corpus-id', 'WPD'); |
| 145 | me.setAttribute('data-doc-id', 'FFF'); |
| 146 | me.setAttribute('data-text-id', '01460'); |
Akron | 0a6768f | 2016-07-13 18:00:43 +0200 | [diff] [blame] | 147 | me.setAttribute('data-text-sigle', 'WPD/FFF/01460'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 148 | me.setAttribute('data-match-id', 'p119-120'); |
| 149 | me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>'; |
| 150 | return me; |
| 151 | }; |
| 152 | |
Akron | cdb0baa | 2016-11-07 01:52:11 +0100 | [diff] [blame] | 153 | function matchElementReal () { |
| 154 | var me = document.createElement('em'); |
| 155 | me.innerHTML = |
| 156 | '<li data-match-id="p85183-85184"' + |
| 157 | ' data-text-sigle="GOE/AGI/00000"' + |
| 158 | ' 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"' + |
| 159 | ' 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"}"' + |
| 160 | ' id="GOE/AGI/00000#p85183-85184">' + |
| 161 | '<div>' + |
| 162 | '<div class="flag"></div>' + |
| 163 | '<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>' + |
| 164 | '</div>' + |
| 165 | '<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>' + |
| 166 | '</li>'; |
| 167 | return me.firstChild; |
| 168 | }; |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 169 | |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 170 | define(['match', 'hint/foundries/cnx', 'hint/foundries/mate'], function () { |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 171 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 172 | // Override getMatchInfo API call |
| 173 | KorAP.API.getMatchInfo = function (x, param, cb) { |
| 174 | if (param['spans'] === undefined || param['spans'] === false) |
| 175 | cb({ "snippet": snippet }); |
| 176 | else |
| 177 | cb({ "snippet": treeSnippet }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 178 | }; |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 179 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 180 | describe('KorAP.InfoLayer', function () { |
| 181 | |
| 182 | var infoClass = require('match/infolayer'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 183 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 184 | it('should be initializable', function () { |
| 185 | expect( |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 186 | function() { infoClass.create() } |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 187 | ).toThrow(new Error("Missing parameters")); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 188 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 189 | expect( |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 190 | function() { infoClass.create("base") } |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 191 | ).toThrow(new Error("Missing parameters")); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 192 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 193 | var layer = infoClass.create("base", "s"); |
| 194 | expect(layer).toBeTruthy(); |
| 195 | expect(layer.foundry).toEqual("base"); |
| 196 | expect(layer.layer).toEqual("s"); |
| 197 | expect(layer.type).toEqual("tokens"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 198 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 199 | layer = infoClass.create("cnx", "syn", "spans"); |
| 200 | expect(layer).toBeTruthy(); |
| 201 | expect(layer.foundry).toEqual("cnx"); |
| 202 | expect(layer.layer).toEqual("syn"); |
| 203 | expect(layer.type).toEqual("spans"); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 204 | }); |
| 205 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 206 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 207 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 208 | describe('KorAP.Match', function () { |
| 209 | var match = { |
| 210 | 'corpusID' : 'WPD', |
| 211 | 'docID' : 'UUU', |
| 212 | 'textID' : '01912', |
| 213 | 'matchID' : 'p121-122', |
Akron | 0a6768f | 2016-07-13 18:00:43 +0200 | [diff] [blame] | 214 | 'textSigle' : 'WPD/UUU/01912', |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 215 | 'available' : available |
| 216 | }; |
| 217 | |
| 218 | var matchClass = require('match'); |
| 219 | |
| 220 | it('should be initializable by Object', function () { |
| 221 | expect(function() { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 222 | matchClass.create() |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 223 | }).toThrow(new Error('Missing parameters')); |
| 224 | |
| 225 | expect(matchClass.create(match)).toBeTruthy(); |
| 226 | |
| 227 | var m = matchClass.create(match); |
Akron | 0a6768f | 2016-07-13 18:00:43 +0200 | [diff] [blame] | 228 | expect(m.textSigle).toEqual("WPD/UUU/01912"); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 229 | expect(m.matchID).toEqual("p121-122"); |
| 230 | |
| 231 | // /corpus/WPD/UUU.01912/p121-122/matchInfo?spans=false&foundry=* |
| 232 | var m = matchClass.create(match); |
| 233 | |
| 234 | // Spans: |
| 235 | var spans = m.getSpans(); |
| 236 | expect(spans[0].foundry).toEqual("base"); |
| 237 | expect(spans[0].layer).toEqual("s"); |
| 238 | |
| 239 | expect(spans[1].foundry).toEqual("corenlp"); |
| 240 | expect(spans[1].layer).toEqual("c"); |
| 241 | |
| 242 | expect(spans[2].foundry).toEqual("corenlp"); |
| 243 | expect(spans[2].layer).toEqual("s"); |
| 244 | |
| 245 | expect(spans[spans.length-1].foundry).toEqual("tt"); |
| 246 | expect(spans[spans.length-1].layer).toEqual("s"); |
| 247 | |
| 248 | // Tokens: |
| 249 | var tokens = m.getTokens(); |
| 250 | expect(tokens[0].foundry).toEqual("corenlp"); |
| 251 | expect(tokens[0].layer).toEqual("ne"); |
| 252 | |
| 253 | expect(tokens[1].foundry).toEqual("corenlp"); |
| 254 | expect(tokens[1].layer).toEqual("p"); |
| 255 | |
| 256 | expect(tokens[tokens.length-1].foundry).toEqual("tt"); |
| 257 | expect(tokens[tokens.length-1].layer).toEqual("p"); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 258 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 259 | |
| 260 | |
Akron | cdb0baa | 2016-11-07 01:52:11 +0100 | [diff] [blame] | 261 | it('should be initializable by Node 1', function () { |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 262 | var m = matchClass.create(matchElementFactory()); |
Akron | 0a6768f | 2016-07-13 18:00:43 +0200 | [diff] [blame] | 263 | expect(m.textSigle).toEqual("WPD/FFF/01460"); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 264 | expect(m.matchID).toEqual("p119-120"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 265 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 266 | // Spans: |
| 267 | var spans = m.getSpans(); |
| 268 | expect(spans[0].foundry).toEqual("base"); |
| 269 | expect(spans[0].layer).toEqual("s"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 270 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 271 | expect(spans[1].foundry).toEqual("corenlp"); |
| 272 | expect(spans[1].layer).toEqual("c"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 273 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 274 | expect(spans[2].foundry).toEqual("corenlp"); |
| 275 | expect(spans[2].layer).toEqual("s"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 276 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 277 | expect(spans[spans.length-1].foundry).toEqual("tt"); |
| 278 | expect(spans[spans.length-1].layer).toEqual("s"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 279 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 280 | // Tokens: |
| 281 | var tokens = m.getTokens(); |
| 282 | expect(tokens[0].foundry).toEqual("corenlp"); |
| 283 | expect(tokens[0].layer).toEqual("ne"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 284 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 285 | expect(tokens[1].foundry).toEqual("corenlp"); |
| 286 | expect(tokens[1].layer).toEqual("p"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 287 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 288 | expect(tokens[tokens.length-1].foundry).toEqual("tt"); |
| 289 | expect(tokens[tokens.length-1].layer).toEqual("p"); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 290 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 291 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 292 | |
Akron | cdb0baa | 2016-11-07 01:52:11 +0100 | [diff] [blame] | 293 | it('should be initializable by Node 2', function () { |
| 294 | var ele = matchElementReal(); |
| 295 | var m = matchClass.create(ele); |
| 296 | expect(m.textSigle).toEqual("GOE/AGI/00000"); |
| 297 | expect(m.matchID).toEqual("p85183-85184"); |
| 298 | }); |
| 299 | |
| 300 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 301 | it('should react to gui actions', function () { |
| 302 | var e = matchElementFactory(); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 303 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 304 | expect(e.classList.contains('active')).toBe(false); |
| 305 | expect(e["_match"]).toBe(undefined); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 306 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 307 | var m = matchClass.create(e); |
| 308 | |
| 309 | expect(e.classList.contains('active')).toBe(false); |
| 310 | expect(e["_match"]).not.toBe(undefined); |
| 311 | |
| 312 | // Open the match |
| 313 | m.open(); |
| 314 | |
| 315 | expect(e.classList.contains('active')).toBe(true); |
| 316 | expect(e["_match"]).not.toBe(undefined); |
| 317 | |
| 318 | // Close the match |
| 319 | m.close(); |
| 320 | expect(e.classList.contains('active')).toBe(false); |
| 321 | expect(e["_match"]).not.toBe(undefined); |
| 322 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 323 | }); |
| 324 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 325 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 326 | |
| 327 | describe('KorAP.MatchInfo', function () { |
| 328 | |
| 329 | var matchClass = require('match'); |
| 330 | |
| 331 | var m = matchClass.create(match); |
| 332 | var info = m.info(); |
| 333 | |
| 334 | it('should contain a valid info', function () { |
| 335 | expect(m._info).toEqual(info); |
| 336 | }); |
| 337 | |
| 338 | var table1, table2; |
| 339 | |
| 340 | // Async preparation |
| 341 | it('should fail to load a table async', function (done) { |
| 342 | expect(info).toBeTruthy(); |
| 343 | |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 344 | info.getTableData([], function (tablen) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 345 | table1 = tablen; |
| 346 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 347 | }); |
| 348 | }); |
| 349 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 350 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 351 | it('should\'nt be parsable (async)', function () { |
| 352 | expect(table1).not.toBeTruthy(); |
| 353 | }); |
| 354 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 355 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 356 | it('should load a working table async', function(done) { |
| 357 | expect(info).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 358 | info.getTableData(undefined, function (tablem) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 359 | table2 = tablem; |
| 360 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 361 | }); |
| 362 | }); |
| 363 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 364 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 365 | it('should parse into a table (async)', function () { |
| 366 | expect(table2).toBeTruthy(); |
| 367 | |
| 368 | expect(table2.length()).toBe(3); |
| 369 | |
| 370 | expect(table2.getToken(0)).toBe("meist"); |
| 371 | expect(table2.getToken(1)).toBe("deutlich"); |
| 372 | expect(table2.getToken(2)).toBe("leistungsfähiger"); |
| 373 | |
| 374 | expect(table2.getValue(0, "cnx", "p")[0]).toBe("ADV"); |
| 375 | expect(table2.getValue(0, "cnx", "syn")[0]).toBe("@PREMOD"); |
Akron | 916ec25 | 2016-11-10 17:06:32 +0100 | [diff] [blame] | 376 | expect(table2.getValue(0, "mate", "l")[0]).toBe("meist"); |
| 377 | expect(table2.getValue(0, "mate", "l")[1]).toBeUndefined(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 378 | |
| 379 | expect(table2.getValue(2, "cnx", "l")[0]).toBe("fähig"); |
| 380 | expect(table2.getValue(2, "cnx", "l")[1]).toBe("leistung"); |
| 381 | }); |
| 382 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 383 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 384 | it('should parse into a table view', function () { |
| 385 | var matchElement = matchElementFactory(); |
| 386 | expect(matchElement.tagName).toEqual('LI'); |
| 387 | |
| 388 | // Match |
| 389 | expect(matchElement.children[0].tagName).toEqual('DIV'); |
| 390 | |
| 391 | // snippet |
| 392 | expect(matchElement.children[0].children[0].tagName).toEqual('DIV'); |
| 393 | expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy(); |
| 394 | expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check'); |
| 395 | |
| 396 | // reference |
| 397 | expect(matchElement.children[1].classList.contains('ref')).toBeTruthy(); |
| 398 | expect(matchElement.children[1].firstChild.nodeValue).toEqual('me'); |
| 399 | |
| 400 | // not yet |
| 401 | expect(matchElement.children[0].children[1]).toBe(undefined); |
| 402 | |
| 403 | var info = matchClass.create(matchElement).info(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 404 | info.showTable(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 405 | |
| 406 | // Match |
| 407 | expect(matchElement.children[0].tagName).toEqual('DIV'); |
| 408 | |
| 409 | // snippet |
| 410 | expect(matchElement.children[0].children[0].tagName).toEqual('DIV'); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 411 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 412 | expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 413 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 414 | expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check'); |
| 415 | |
| 416 | // reference |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 417 | expect(matchElement.lastChild.classList.contains('ref')).toBeTruthy(); |
| 418 | expect(matchElement.lastChild.firstChild.nodeValue).toEqual('me'); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 419 | |
| 420 | // now |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 421 | var infotable = matchElement.children[1]; |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 422 | expect(infotable.tagName).toEqual('DIV'); |
Akron | aa7fce5 | 2017-06-30 21:15:18 +0200 | [diff] [blame] | 423 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 424 | expect(infotable.classList.contains('matchinfo')).toBeTruthy(); |
| 425 | |
| 426 | expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 427 | // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 428 | }); |
| 429 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 430 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 431 | var tree; |
| 432 | it('should parse into a tree (async) 1', function (done) { |
| 433 | var info = matchClass.create(match).info(); |
| 434 | expect(info).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 435 | info.getTreeData(undefined, undefined, "spans", function (treem) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 436 | tree = treem; |
| 437 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 438 | }); |
| 439 | }); |
| 440 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 441 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 442 | it('should parse into a tree (async) 2', function () { |
| 443 | expect(tree).toBeTruthy(); |
| 444 | expect(tree.nodes()).toEqual(49); |
| 445 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 446 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 447 | |
Akron | 98a933f | 2016-08-11 00:19:17 +0200 | [diff] [blame] | 448 | var matchElement, info; |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 449 | |
Akron | 98a933f | 2016-08-11 00:19:17 +0200 | [diff] [blame] | 450 | // var info, matchElement; |
| 451 | it('should parse into a tree view', function () { |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 452 | matchElement = matchElementFactory(); |
| 453 | expect(matchElement.tagName).toEqual('LI'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 454 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 455 | info = matchClass.create(matchElement).info(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 456 | info.showTable(); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 457 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 458 | // Match |
| 459 | expect(matchElement.children[0].tagName).toEqual('DIV'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 460 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 461 | // snippet |
| 462 | expect(matchElement.children[0].children[0].tagName).toEqual('DIV'); |
| 463 | expect(matchElement.children[0].children[0].classList.contains('snippet')).toBeTruthy(); |
| 464 | expect(matchElement.children[0].children[0].firstChild.nodeValue).toEqual('check'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 465 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 466 | // reference |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 467 | expect(matchElement.lastChild.classList.contains('ref')).toBeTruthy(); |
| 468 | expect(matchElement.lastChild.firstChild.nodeValue).toEqual('me'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 469 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 470 | // now |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 471 | var infotable = matchElement.children[1]; |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 472 | expect(infotable.tagName).toEqual('DIV'); |
| 473 | expect(infotable.classList.contains('matchinfo')).toBeTruthy(); |
| 474 | expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 475 | // expect(infotable.children[1].classList.contains('addtree')).toBeTruthy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 476 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 477 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 478 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 479 | it('should add a tree view async 1', function (done) { |
| 480 | expect(info).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 481 | info.showTree('mate', 'beebop', "spans", function () { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 482 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 483 | }); |
| 484 | }); |
| 485 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 486 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 487 | it('should add a tree view async 2', function () { |
| 488 | // With added tree |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 489 | var infotable = matchElement.children[1]; |
| 490 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 491 | expect(infotable.tagName).toEqual('DIV'); |
| 492 | expect(infotable.classList.contains('matchinfo')).toBeTruthy(); |
| 493 | expect(infotable.children[0].classList.contains('matchtable')).toBeTruthy(); |
| 494 | expect(infotable.children[1].classList.contains('addtree')).toBe(false); |
| 495 | |
| 496 | var tree = infotable.children[1]; |
| 497 | expect(tree.tagName).toEqual('DIV'); |
| 498 | expect(tree.classList.contains('matchtree')).toBeTruthy(); |
| 499 | expect(tree.children[0].tagName).toEqual('H6'); |
| 500 | expect(tree.children[0].children[0].tagName).toEqual('SPAN'); |
| 501 | expect(tree.children[0].children[0].firstChild.nodeValue).toEqual('mate'); |
| 502 | expect(tree.children[0].children[1].tagName).toEqual('SPAN'); |
| 503 | expect(tree.children[0].children[1].firstChild.nodeValue).toEqual('beebop'); |
| 504 | |
| 505 | expect(tree.children[1].tagName).toEqual('DIV'); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 506 | }); |
| 507 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 508 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 509 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 510 | describe('KorAP.MatchTable', function () { |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 511 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 512 | var matchClass = require('match'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 513 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 514 | var table; |
| 515 | it('should be retrieved async', function (done) { |
| 516 | var info = matchClass.create(match).info(); |
| 517 | expect(info).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 518 | info.getTableData(undefined, function (x) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 519 | table = x; |
| 520 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 521 | }); |
| 522 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 523 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 524 | it('should be rendered async', function () { |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 525 | |
| 526 | var e = table.element().firstChild; |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 527 | expect(e.nodeName).toBe('TABLE'); |
| 528 | expect(e.children[0].nodeName).toBe('THEAD'); |
| 529 | var tr = e.children[0].children[0]; |
| 530 | expect(tr.nodeName).toBe('TR'); |
| 531 | expect(tr.children[0].nodeName).toBe('TH'); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 532 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 533 | expect(tr.children[0].firstChild.nodeValue).toBe('Foundry'); |
| 534 | expect(tr.children[1].firstChild.nodeValue).toBe('Layer'); |
| 535 | expect(tr.children[2].firstChild.nodeValue).toBe('meist'); |
| 536 | expect(tr.children[3].firstChild.nodeValue).toBe('deutlich'); |
| 537 | expect(tr.children[4].firstChild.nodeValue).toBe('leistungsfähiger'); |
| 538 | |
| 539 | // first row |
| 540 | tr = e.children[1].children[0]; |
| 541 | expect(tr.nodeName).toBe('TR'); |
| 542 | expect(tr.getAttribute('tabindex')).toEqual('0'); |
| 543 | expect(tr.children[0].nodeName).toBe('TH'); |
| 544 | expect(tr.children[0].firstChild.nodeValue).toEqual('cnx'); |
| 545 | expect(tr.children[1].firstChild.nodeValue).toEqual('l'); |
| 546 | expect(tr.children[2].firstChild.nodeValue).toEqual('meist'); |
| 547 | expect(tr.children[3].firstChild.nodeValue).toEqual('deutlich'); |
Akron | 47774c4 | 2017-07-03 20:14:55 +0200 | [diff] [blame] | 548 | expect(tr.children[4].firstChild.firstChild.nodeValue).toEqual('fähig'); |
| 549 | expect(tr.children[4].lastChild.firstChild.nodeValue).toEqual('leistung'); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 550 | |
| 551 | // second row |
| 552 | tr = e.children[1].children[1]; |
| 553 | expect(tr.nodeName).toBe('TR'); |
| 554 | expect(tr.getAttribute('tabindex')).toEqual('0'); |
| 555 | expect(tr.children[0].nodeName).toBe('TH'); |
| 556 | expect(tr.children[0].firstChild.nodeValue).toEqual('cnx'); |
| 557 | expect(tr.children[1].firstChild.nodeValue).toEqual('p'); |
| 558 | expect(tr.children[2].firstChild.nodeValue).toEqual('ADV'); |
| 559 | expect(tr.children[3].firstChild.nodeValue).toEqual('A'); |
Akron | 47774c4 | 2017-07-03 20:14:55 +0200 | [diff] [blame] | 560 | expect(tr.children[4].firstChild.firstChild.nodeValue).toEqual('A'); |
| 561 | expect(tr.children[4].lastChild.firstChild.nodeValue).toEqual('ADJA'); |
Akron | f2279c4 | 2017-12-21 13:48:46 +0100 | [diff] [blame] | 562 | |
| 563 | expect(tr.children[4].firstChild.getAttribute("title")).toEqual('Adjective'); |
| 564 | expect(tr.children[2].getAttribute("title")).toEqual('Adverb'); |
| 565 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 566 | }); |
| 567 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 568 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 569 | describe('KorAP.MatchTree', function () { |
| 570 | var tree; |
| 571 | var matchClass = require('match'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 572 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 573 | it('should be rendered async 1', function (done) { |
| 574 | var info = matchClass.create(match).info(); |
| 575 | expect(info).toBeTruthy(); |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 576 | info.getTreeData(undefined, undefined, "spans", function (y) { |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 577 | tree = y; |
| 578 | done(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 579 | }); |
| 580 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 581 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 582 | it('should be rendered async 2', function () { |
| 583 | var e = tree.element(); |
| 584 | expect(e.nodeName).toEqual('svg'); |
| 585 | expect(e.getElementsByTagName('g').length).toEqual(48); |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 586 | }); |
| 587 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 588 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 589 | |
| 590 | describe('KorAP.MatchTreeItem', function () { |
| 591 | var matchTreeItemClass = require('match/treeitem'); |
| 592 | it('should be initializable', function () { |
| 593 | var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c']) |
| 594 | expect(mi.element().firstChild.nodeValue).toEqual('cnx/c'); |
| 595 | expect(mi.lcField()).toEqual(' cnx/c'); |
| 596 | expect(mi.foundry()).toEqual('cnx'); |
| 597 | expect(mi.layer()).toEqual('c'); |
| 598 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 599 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 600 | |
| 601 | |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 602 | describe('KorAP.MatchRelation', function () { |
Akron | 41387d2 | 2018-02-02 18:10:06 +0100 | [diff] [blame] | 603 | var relClass = require('match/treearc') |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 604 | |
| 605 | var relExample = "<span class=\"context-left\"></span>" + |
| 606 | "<span class=\"match\">" + |
| 607 | " <span xml:id=\"token-GOE/AGA/01784-p199\">" + |
| 608 | " <span xlink:title=\"malt/d:ADV\" " + |
| 609 | " xlink:type=\"simple\" " + |
| 610 | " xlink:href=\"#token-GOE/AGA/01784-p199\">dann</span>" + |
| 611 | " </span>" + |
| 612 | " zog " + |
| 613 | " <span xlink:title=\"malt/d:SUBJ\" " + |
| 614 | " xlink:type=\"simple\" " + |
| 615 | " xlink:href=\"#token-GOE/AGA/01784-p199\">ich</span>" + |
| 616 | " <span xml:id=\"token-GOE/AGA/01784-p202\">" + |
| 617 | " <span xlink:title=\"malt/d:OBJA\" " + |
| 618 | " xlink:type=\"simple\" " + |
| 619 | " xlink:href=\"#token-GOE/AGA/01784-p199\">mich</span>" + |
| 620 | " </span>" + |
| 621 | "</span>" + |
| 622 | "<span class=\"context-right\"></span>"; |
| 623 | |
| 624 | |
| 625 | it('should be initializable', function () { |
| 626 | var tree = relClass.create(); |
| 627 | expect(tree.size()).toBe(0); |
| 628 | }); |
| 629 | |
| 630 | it('should be parse string data', function () { |
| 631 | var tree = relClass.create(relExample); |
| 632 | expect(tree.size()).toBe(4); |
| 633 | }); |
| 634 | |
| 635 | |
| 636 | }); |
| 637 | |
| 638 | |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 639 | describe('KorAP.MatchTreeMenu', function () { |
| 640 | var matchTreeMenu = require('match/treemenu'); |
| 641 | var matchTreeItem = require('match/treeitem'); |
| 642 | |
| 643 | it('should be initializable', function () { |
Akron | 5b1a6af | 2018-02-05 15:41:16 +0100 | [diff] [blame^] | 644 | var menu = matchTreeMenu.create([ |
Akron | 671fdb9 | 2017-09-12 18:09:46 +0200 | [diff] [blame] | 645 | ['cnx/c', 'cnx', 'c'], |
| 646 | ['xip/c', 'xip', 'c'] |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 647 | ]); |
| 648 | |
| 649 | expect(menu.itemClass()).toEqual(matchTreeItem); |
| 650 | expect(menu.element().nodeName).toEqual('UL'); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 651 | expect(menu.element().classList.contains('visible')).toBeFalsy(); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 652 | expect(menu.limit()).toEqual(6); |
| 653 | menu.show(); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 654 | expect(menu.element().classList.contains('visible')).toBeTruthy(); |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 655 | expect(menu.item(0).active()).toBe(false); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 656 | }); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 657 | }); |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 658 | |
| 659 | // table = view.toTable(); |
| 660 | // table.sortBy(''); |
| 661 | // table.element(); |
| 662 | // tree = view.toTree(); |
| 663 | // tree.element(); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 664 | }); |