hebasta | 5e4d754 | 2018-06-19 16:57:36 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Test suite for corpus statistic |
| 3 | * |
| 4 | * @author Helge Stallkamp |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 5 | * @author Nils Diewald |
hebasta | 5e4d754 | 2018-06-19 16:57:36 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | |
hebasta | 6c8f09d | 2018-07-24 13:21:36 +0200 | [diff] [blame] | 9 | define(['vc', 'vc/statistic', 'view/corpstatv'], function(vcClass, statClass, corpStatVClass){ |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 10 | |
hebasta | 47d03a4 | 2018-06-25 10:31:58 +0200 | [diff] [blame] | 11 | var json = { |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 12 | "@type":"koral:docGroup", |
| 13 | "operation":"operation:or", |
| 14 | "operands":[ |
| 15 | { |
| 16 | "@type":"koral:docGroup", |
| 17 | "operation":"operation:and", |
| 18 | "operands":[ |
| 19 | { |
| 20 | "@type":"koral:doc", |
| 21 | "key":"title", |
| 22 | "value":"Der Birnbaum", |
| 23 | "match":"match:eq" |
| 24 | }, |
| 25 | { |
| 26 | "@type":"koral:doc", |
| 27 | "key":"pubPlace", |
| 28 | "value":"Mannheim", |
| 29 | "type" : "type:regex", |
| 30 | "match":"match:contains" |
| 31 | }, |
| 32 | { |
| 33 | "@type":"koral:docGroup", |
| 34 | "operation":"operation:or", |
| 35 | "operands":[ |
| 36 | { |
| 37 | "@type":"koral:doc", |
| 38 | "key":"subTitle", |
| 39 | "value":"Aufzucht und Pflege", |
| 40 | "match":"match:eq" |
| 41 | }, |
| 42 | { |
| 43 | "@type":"koral:doc", |
| 44 | "key":"subTitle", |
| 45 | "value":"Gedichte", |
| 46 | "match":"match:eq", |
| 47 | "rewrites" : [ |
| 48 | { |
| 49 | "@type": "koral:rewrite", |
| 50 | "src" : "policy", |
| 51 | "operation" : "operation:injection", |
| 52 | } |
| 53 | ] |
| 54 | } |
| 55 | ] |
| 56 | } |
| 57 | ] |
| 58 | }, |
| 59 | { |
| 60 | "@type":"koral:doc", |
| 61 | "key":"pubDate", |
| 62 | "type":"type:date", |
| 63 | "value":"2015-03-05", |
| 64 | "match":"match:geq" |
| 65 | } |
| 66 | ] |
| 67 | }; |
hebasta | 5e4d754 | 2018-06-19 16:57:36 +0200 | [diff] [blame] | 68 | |
hebasta | 47d03a4 | 2018-06-25 10:31:58 +0200 | [diff] [blame] | 69 | var preDefinedStat={ |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 70 | "documents":12, |
| 71 | "tokens":2323, |
| 72 | "sentences":343434, |
| 73 | "paragraphs":45454545 |
hebasta | 47d03a4 | 2018-06-25 10:31:58 +0200 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | KorAP.API.getCorpStat = function(collQu, cb){ |
| 77 | return cb(preDefinedStat); |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 78 | }; |
| 79 | |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 80 | |
| 81 | generateCorpusDocGr = function(){ |
| 82 | let vc = vcClass.create().fromJson({ |
| 83 | "@type" : 'koral:docGroup', |
| 84 | 'operation' : 'operation:or', |
| 85 | 'operands' : [ |
| 86 | { |
| 87 | '@type' : 'koral:doc', |
| 88 | 'key' : 'title', |
| 89 | 'match': 'match:eq', |
| 90 | 'value' : 'Hello World!' |
| 91 | }, |
| 92 | { |
| 93 | '@type' : 'koral:doc', |
| 94 | 'match': 'match:eq', |
| 95 | 'key' : 'foo', |
| 96 | 'value' : 'bar' |
| 97 | } |
| 98 | ] |
| 99 | }); |
| 100 | return vc; |
| 101 | } |
| 102 | |
| 103 | generateCorpusDoc = function(){ |
| 104 | let vc= vcClass.create().fromJson({ |
| 105 | '@type' : 'koral:doc', |
| 106 | 'key' : 'title', |
| 107 | 'match': 'match:eq', |
| 108 | 'value' : 'Hello World!', |
| 109 | 'type' : 'type:string' |
| 110 | }); |
| 111 | return vc; |
| 112 | }; |
| 113 | |
| 114 | |
| 115 | /** |
| 116 | * Generate vc with docgroupref |
| 117 | */ |
| 118 | generateCorpusRef = function(){ |
| 119 | let vc = vcClass.create().fromJson({ |
| 120 | "@type" : "koral:docGroupRef", |
| 121 | "ref" : "@max/myCorpus" |
| 122 | }); |
| 123 | return vc; |
| 124 | }; |
| 125 | |
| 126 | |
| 127 | /** |
| 128 | * Checks is corpus statistic is active |
| 129 | */ |
| 130 | checkStatActive = function(view, div){ |
| 131 | // corpus statistic exists, it is active and reloadStatButton is shown |
| 132 | if ((view.firstChild.classList.contains("stattable") === true) |
| 133 | && (view.firstChild.classList.contains("greyOut") === false) |
| 134 | && (div.getElementsByClassName("reloadStatB").length == 0) ) { |
| 135 | return true; |
| 136 | } |
| 137 | return false; |
| 138 | }; |
| 139 | |
| 140 | |
| 141 | /** |
| 142 | * Checks if corpus statistic is disabled |
| 143 | */ |
| 144 | checkStatDisabled = function(view, div){ |
| 145 | if ((view.firstChild.classList.contains("stattable") === true) |
| 146 | && (view.firstChild.classList.contains("greyOut") === true) |
| 147 | && (div.getElementsByClassName("reloadStatB").length === 1) ) { |
| 148 | return true; |
| 149 | } |
| 150 | return false; |
| 151 | }; |
| 152 | |
| 153 | |
| 154 | describe('KorAP.CorpusStat', function(){ |
hebasta | 47d03a4 | 2018-06-25 10:31:58 +0200 | [diff] [blame] | 155 | |
hebasta | 5e4d754 | 2018-06-19 16:57:36 +0200 | [diff] [blame] | 156 | it('should be initiable', function(){ |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 157 | var stat = statClass.create(preDefinedStat); |
hebasta | 5e4d754 | 2018-06-19 16:57:36 +0200 | [diff] [blame] | 158 | expect( function() { statClass.create() }).toThrow(new Error("Missing parameter")); |
| 159 | }); |
| 160 | |
| 161 | |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 162 | it('should be parsed in a statistic view and displayed as HTML Description List', function(){ |
| 163 | var stat = statClass.create(preDefinedStat); |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 164 | var descL = stat.element(); |
hebasta | 5e4d754 | 2018-06-19 16:57:36 +0200 | [diff] [blame] | 165 | expect(descL.tagName).toEqual('DL'); |
| 166 | expect(descL.children[0].tagName).toEqual('DIV'); |
| 167 | expect(descL.children[0].children[0].tagName).toEqual('DT'); |
| 168 | expect(descL.children[0].children[0].attributes[0].name).toEqual('title'); |
| 169 | expect(descL.children[0].children[1].tagName).toEqual('DD'); |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 170 | |
hebasta | 5e4d754 | 2018-06-19 16:57:36 +0200 | [diff] [blame] | 171 | expect(descL.children[0].children[0].firstChild.nodeValue).toEqual('documents'); |
| 172 | expect(descL.children[0].children[1].firstChild.nodeValue).toEqual('12'); |
| 173 | expect(descL.children[0].children[0].attributes[0].value).toEqual('documents'); |
Akron | 2f97912 | 2018-07-25 17:00:23 +0200 | [diff] [blame] | 174 | |
| 175 | expect(descL.children[1].children[0].firstChild.nodeValue).toEqual('tokens'); |
| 176 | expect(descL.children[1].children[1].firstChild.nodeValue).toEqual(new Number(2323).toLocaleString()); |
| 177 | expect(descL.children[1].children[0].attributes[0].value).toEqual('tokens'); |
| 178 | }); |
hebasta | 5e4d754 | 2018-06-19 16:57:36 +0200 | [diff] [blame] | 179 | |
hebasta | 47d03a4 | 2018-06-25 10:31:58 +0200 | [diff] [blame] | 180 | |
hebasta | 6c8f09d | 2018-07-24 13:21:36 +0200 | [diff] [blame] | 181 | it('should display corpus statistic after creating a corpus statistic view', function(){ |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 182 | var vc = vcClass.create([ |
| 183 | ['title', 'string'], |
| 184 | ['subTitle', 'string'], |
| 185 | ['pubDate', 'date'], |
| 186 | ['author', 'text'] |
| 187 | ]).fromJson(json); |
| 188 | |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 189 | KorAP.vc = vc; |
| 190 | |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 191 | statView = corpStatVClass.create(vc); |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 192 | // corpStatVClass.show(vc); |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 193 | |
hebasta | 47d03a4 | 2018-06-25 10:31:58 +0200 | [diff] [blame] | 194 | var testDiv = document.createElement('div'); |
hebasta | 6c8f09d | 2018-07-24 13:21:36 +0200 | [diff] [blame] | 195 | testDiv.appendChild(statView.show()); |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 196 | // statClass.showCorpStat(testDiv, vc); |
hebasta | 47d03a4 | 2018-06-25 10:31:58 +0200 | [diff] [blame] | 197 | |
| 198 | expect(testDiv.children[0].tagName).toEqual('DIV'); |
| 199 | expect(testDiv.children[0].getAttribute("class")).toEqual('stattable'); |
| 200 | expect(testDiv.children[0].children[0].tagName).toEqual('DL'); |
| 201 | expect(testDiv.children[0].children[0].children[0].children[0].firstChild.nodeValue).toEqual('documents'); |
| 202 | expect(testDiv.children[0].children[0].children[0].children[1].firstChild.nodeValue).toEqual('12'); |
hebasta | 47d03a4 | 2018-06-25 10:31:58 +0200 | [diff] [blame] | 203 | }); |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 204 | |
| 205 | it('should display the statistics button in a panel', function () { |
| 206 | var vc = vcClass.create([ |
| 207 | ['title', 'string'], |
| 208 | ['subTitle', 'string'], |
| 209 | ['pubDate', 'date'], |
| 210 | ['author', 'text'] |
| 211 | ]).fromJson(json); |
| 212 | |
| 213 | var show = document.createElement('div'); |
| 214 | |
| 215 | show.appendChild(vc.element()); |
| 216 | |
| 217 | var panel = show.firstChild.lastChild.firstChild; |
| 218 | expect(panel.classList.contains('panel')).toBeTruthy(); |
| 219 | expect(panel.classList.contains('vcinfo')).toBeTruthy(); |
| 220 | expect(panel.lastChild.classList.contains('button-group')).toBeTruthy(); |
| 221 | expect(panel.lastChild.classList.contains('vcinfo')).toBeTruthy(); |
| 222 | expect(panel.lastChild.children[0].tagName).toEqual('SPAN'); |
| 223 | expect(panel.lastChild.children[0].textContent).toEqual('Statistics'); |
| 224 | }); |
| 225 | |
| 226 | |
| 227 | it('should display the statistics button in a panel after VC modification', function () { |
| 228 | |
| 229 | var vc = vcClass.create([ |
| 230 | ['title', 'string'], |
| 231 | ['subTitle', 'string'], |
| 232 | ['pubDate', 'date'], |
| 233 | ['author', 'text'] |
| 234 | ]).fromJson(json); |
| 235 | |
| 236 | var show = document.createElement('div'); |
| 237 | |
| 238 | show.appendChild(vc.element()); |
| 239 | |
| 240 | expect(show.querySelector(".statistic").tagName).toEqual("SPAN"); |
| 241 | |
Akron | adab5e5 | 2018-08-20 13:50:53 +0200 | [diff] [blame] | 242 | var and = vc.builder().lastChild.firstChild; |
Akron | 18a99c0 | 2018-08-20 12:55:14 +0200 | [diff] [blame] | 243 | |
| 244 | // Click on and() in VC |
| 245 | and.click(); |
| 246 | |
| 247 | // Check that statistics is there |
| 248 | expect(show.querySelector(".statistic").tagName).toEqual("SPAN"); |
| 249 | }); |
| 250 | |
| 251 | |
| 252 | it('should display and hide corpus statistics view in the panel', function () { |
| 253 | |
| 254 | var vc = vcClass.create([ |
| 255 | ['title', 'string'], |
| 256 | ['subTitle', 'string'], |
| 257 | ['pubDate', 'date'], |
| 258 | ['author', 'text'] |
| 259 | ]).fromJson(json); |
| 260 | |
| 261 | var show = document.createElement('div'); |
| 262 | |
| 263 | show.appendChild(vc.element()); |
| 264 | |
| 265 | var panel = show.firstChild.lastChild.firstChild; |
| 266 | |
| 267 | // Show statistics |
| 268 | panel.lastChild.children[0].click(); |
| 269 | |
| 270 | // Statistics view |
| 271 | var viewE = panel.firstChild.firstChild; |
| 272 | |
| 273 | expect(viewE.tagName).toEqual("DIV"); |
| 274 | expect(viewE.classList.contains("view")).toBeTruthy(); |
| 275 | expect(viewE.classList.contains("vcstatistic")).toBeTruthy(); |
| 276 | |
| 277 | expect(viewE.firstChild.classList.contains("stattable")).toBeTruthy(); |
| 278 | expect(viewE.firstChild.firstChild.tagName).toEqual("DL"); |
| 279 | |
| 280 | // List of statistic values |
| 281 | var dl = viewE.firstChild.firstChild.firstChild; |
| 282 | expect(dl.firstChild.tagName).toEqual("DT"); |
| 283 | expect(dl.firstChild.textContent).toEqual("documents"); |
| 284 | expect(dl.lastChild.tagName).toEqual("DD"); |
| 285 | expect(dl.lastChild.textContent).toEqual("12"); |
| 286 | |
| 287 | expect(viewE.children.length).toEqual(2); |
| 288 | |
| 289 | expect(viewE.lastChild.classList.contains("button-group")).toBeTruthy(); |
| 290 | expect(viewE.lastChild.children.length).toEqual(1); |
| 291 | expect(viewE.lastChild.firstChild.tagName).toEqual("SPAN"); |
| 292 | expect(viewE.lastChild.firstChild.textContent).toEqual("Close"); |
| 293 | |
| 294 | // Close view |
| 295 | viewE.lastChild.firstChild.firstChild.click(); |
| 296 | |
| 297 | // Is gone |
| 298 | expect(panel.firstChild.children.length).toEqual(0); |
| 299 | |
| 300 | // Show statistics |
| 301 | panel.lastChild.children[0].click(); |
| 302 | |
| 303 | // Is there |
| 304 | expect(panel.firstChild.children.length).toEqual(1); |
| 305 | |
| 306 | // Only show once |
| 307 | panel.lastChild.children[0].click(); |
| 308 | expect(panel.firstChild.children.length).toEqual(1); |
| 309 | }); |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 310 | |
| 311 | |
| 312 | }); |
| 313 | |
| 314 | |
| 315 | |
| 316 | /** |
| 317 | * Test disabling and reload of corpus statistic if vc is changed |
| 318 | * in vc builder through user-interaction |
| 319 | */ |
| 320 | describe ('KorAP.CorpusStat.Disable', function(){ |
| 321 | |
| 322 | /** |
| 323 | * If the user defines a new vc, the statistic should be disabled, |
| 324 | * because it is out-of-date. |
| 325 | * |
| 326 | * The user can choose to display an up-to-date corpus statistic. Here it is tested |
| 327 | * if corpus statistic is disabled after a valid change of corpus statistic and if the corpus statistic is updatable. |
| 328 | */ |
| 329 | it ('should disable the corpus statistic if corpus definition is changed and display a functional reload button', function(){ |
| 330 | |
| 331 | KorAP.vc = generateCorpusDocGr(); |
| 332 | |
| 333 | //Show corpus statistic |
| 334 | let show = document.createElement('div'); |
| 335 | show.appendChild(KorAP.vc.element()); |
| 336 | let panel = show.firstChild.lastChild.firstChild; |
| 337 | panel.lastChild.children[0].click(); |
| 338 | let view = panel.firstChild.firstChild; |
| 339 | |
| 340 | //corpus statistic is active |
| 341 | expect(checkStatActive(view, show)).toBe(true); |
| 342 | |
| 343 | //change vc, a line in vc builder is deleted |
| 344 | KorAP._delete.apply(KorAP.vc.root().getOperand(0)); |
| 345 | expect(checkStatDisabled(view,show)).toBe(true); |
| 346 | |
| 347 | //click at reload button |
| 348 | let rlbutton = show.getElementsByClassName("refresh").item(0); |
| 349 | rlbutton.click(); |
| 350 | |
| 351 | expect(checkStatActive(view,show)).toBe(true); |
| 352 | }); |
| 353 | |
| 354 | |
| 355 | it('should disable corpus statistic if entries in vc builder are deleted', function(){ |
| 356 | KorAP.vc = generateCorpusDocGr(); |
| 357 | |
| 358 | // create corpus builder and corpus statistic; |
| 359 | let show = document.createElement('div'); |
| 360 | show.appendChild(KorAP.vc.element()); |
| 361 | let panel = show.firstChild.lastChild.firstChild; |
| 362 | panel.lastChild.children[0].click(); |
| 363 | let view = panel.firstChild.firstChild; |
| 364 | |
| 365 | expect(checkStatActive(view, show)).toBe(true); |
| 366 | |
| 367 | //delete foo=bar |
| 368 | KorAP._delete.apply(KorAP.vc.root().getOperand(1)); |
| 369 | expect(checkStatDisabled(view, show)).toBe(true); |
| 370 | |
| 371 | //refresh corpus statistic |
| 372 | let rlbutton = show.getElementsByClassName("refresh").item(0); |
| 373 | rlbutton.click(); |
| 374 | expect(checkStatActive(view,show)).toBe(true); |
hebasta | 3f4be92 | 2018-12-11 10:41:46 +0100 | [diff] [blame] | 375 | |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 376 | KorAP._delete.apply(KorAP.vc.root()); |
hebasta | 3f4be92 | 2018-12-11 10:41:46 +0100 | [diff] [blame] | 377 | view = panel.firstChild.firstChild; |
| 378 | expect(checkStatDisabled(view, show)).toBe(true); |
| 379 | |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 380 | }); |
| 381 | |
| 382 | |
| 383 | it('should disable corpus statistic if key, matchoperator or value is changed', function(){ |
| 384 | /* |
| 385 | * Doc change of key, match operator and value |
| 386 | */ |
| 387 | KorAP.vc= generateCorpusDoc(); |
| 388 | // show vc builder and open corpus statistic |
| 389 | let show = document.createElement('div'); |
| 390 | show.appendChild(KorAP.vc.element()); |
| 391 | let panel = show.firstChild.lastChild.firstChild; |
| 392 | panel.lastChild.children[0].click(); |
| 393 | let view = panel.firstChild.firstChild; |
| 394 | expect(checkStatActive(view, show)).toBe(true); |
| 395 | |
| 396 | KorAP.vc.root().matchop("ne").update(); |
| 397 | expect(checkStatDisabled(view, show)).toBe(true); |
| 398 | |
| 399 | let rlbutton = show.getElementsByClassName("refresh").item(0); |
| 400 | rlbutton.click(); |
| 401 | |
| 402 | view = panel.firstChild.firstChild; |
| 403 | expect(checkStatActive(view, show)).toBe(true); |
| 404 | KorAP.vc.root().value("Hello tester").update(); |
| 405 | expect(checkStatDisabled(view, show)).toBe(true); |
| 406 | |
| 407 | //refresh corpus statistic |
| 408 | rlbutton = show.getElementsByClassName("refresh").item(0); |
| 409 | rlbutton.click(); |
| 410 | view = panel.firstChild.firstChild; |
| 411 | expect(checkStatActive(view, show)).toBe(true); |
| 412 | |
| 413 | KorAP.vc.root().key("author").update(); |
| 414 | expect(checkStatDisabled(view, show)).toBe(true); |
| 415 | |
| 416 | |
| 417 | /* |
| 418 | * DocGroupRef change of value... |
| 419 | */ |
| 420 | KorAP.vc = generateCorpusRef(); |
| 421 | show = document.createElement('div'); |
| 422 | show.appendChild(KorAP.vc.element()); |
| 423 | panel = show.firstChild.lastChild.firstChild; |
| 424 | panel.lastChild.children[0].click(); |
| 425 | view = panel.firstChild.firstChild; |
| 426 | expect(checkStatActive(view, show)).toBe(true); |
| 427 | |
| 428 | KorAP.vc.root().ref("@anton/secondCorpus").update(); |
| 429 | expect(checkStatDisabled(view, show)).toBe(true); |
| 430 | }); |
| 431 | |
| 432 | |
| 433 | it('should not disable corpus statistic if docgroup definition is incomplete', function(){ |
| 434 | |
| 435 | KorAP.vc = generateCorpusDocGr(); |
| 436 | |
| 437 | //Show corpus statistic |
| 438 | let show = document.createElement('div'); |
| 439 | show.appendChild(KorAP.vc.element()); |
| 440 | let panel = show.firstChild.lastChild.firstChild; |
| 441 | panel.lastChild.children[0].click(); |
| 442 | let view = panel.firstChild.firstChild; |
| 443 | |
| 444 | expect(checkStatActive(view, show)).toBe(true); |
| 445 | |
| 446 | KorAP._and.apply(KorAP.vc.root()); |
| 447 | |
| 448 | let andbuild = show.getElementsByClassName("builder"); |
| 449 | expect(andbuild[0].firstChild.classList.contains('docGroup')).toBeTruthy(); |
| 450 | expect(andbuild[0].firstChild.getAttribute("data-operation")).toEqual("and"); |
| 451 | expect(checkStatActive(view, show)).toBe(true); |
| 452 | }); |
| 453 | |
| 454 | |
| 455 | it('should not disable corpus statistic if doc/docref definition is incomplete', function(){ |
| 456 | |
| 457 | /* |
| 458 | * DOC incomplete |
| 459 | */ |
| 460 | KorAP.vc = vcClass.create().fromJson(); |
| 461 | expect(KorAP.vc.builder().firstChild.classList.contains('unspecified')).toBeTruthy(); |
| 462 | |
| 463 | // show vc builder and open corpus statistic |
| 464 | let show = document.createElement('div'); |
| 465 | show.appendChild(KorAP.vc.element()); |
| 466 | let panel = show.firstChild.lastChild.firstChild; |
| 467 | panel.lastChild.children[0].click(); |
| 468 | let view = panel.firstChild.firstChild; |
| 469 | |
| 470 | // corpus statistic should be shown and be up-to-date, reload button is not shown |
| 471 | expect(checkStatActive(view, show)).toBe(true); |
| 472 | |
| 473 | // open the menu |
| 474 | KorAP.vc.builder().firstChild.firstChild.click(); |
| 475 | KorAP._vcKeyMenu._prefix.add("author"); |
| 476 | let prefElement = KorAP.vc.builder().querySelector('span.pref'); |
| 477 | // add key 'author' to VC |
| 478 | prefElement.click(); |
| 479 | |
| 480 | expect(checkStatActive(view, show)).toBe(true); |
| 481 | |
| 482 | |
| 483 | /* |
| 484 | * DOCREF incomplete |
| 485 | */ |
| 486 | KorAP.vc = vcClass.create().fromJson(); |
| 487 | expect(KorAP.vc.builder().firstChild.classList.contains('unspecified')).toBeTruthy(); |
| 488 | |
| 489 | // show vc builder and open corpus statistic |
| 490 | show = document.createElement('div'); |
| 491 | show.appendChild(KorAP.vc.element()); |
| 492 | panel = show.firstChild.lastChild.firstChild; |
| 493 | panel.lastChild.children[0].click(); |
| 494 | view = panel.firstChild.firstChild; |
| 495 | expect(checkStatActive(view, show)).toBe(true); |
| 496 | |
| 497 | KorAP.vc.builder().firstChild.firstChild.click(); |
| 498 | KorAP._vcKeyMenu._prefix.add("referTo"); |
| 499 | prefElement = KorAP.vc.builder().querySelector('span.pref'); |
| 500 | prefElement.click(); |
| 501 | expect(checkStatActive(view, show)).toBe(true); |
| 502 | }); |
| 503 | }); |
hebasta | 5e4d754 | 2018-06-19 16:57:36 +0200 | [diff] [blame] | 504 | }); |