Akron | 72245b6 | 2018-07-23 10:59:08 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Specification for the query creator. |
| 3 | */ |
| 4 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 5 | function matchTableFactory () { |
| 6 | var table = document.createElement('div'); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 7 | |
| 8 | Element.prototype.innerString = function () { |
| 9 | return this.innerText.split("\n").join(""); |
| 10 | }; |
| 11 | |
| 12 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 13 | table.className = 'matchtable'; |
| 14 | table.innerHTML = |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 15 | " <table>" + |
| 16 | " <thead>" + |
| 17 | " <tr>" + |
| 18 | " <th>Foundry</th>" + |
| 19 | " <th>Layer</th>" + |
| 20 | " <th>Der</th>" + |
| 21 | " <th>älteste</th>" + |
| 22 | " <th>lebende</th>" + |
| 23 | " <th>Baum</th>" + |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 24 | " <th>hier</th>" + |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 25 | " </tr>" + |
| 26 | " </thead>" + |
| 27 | " <tbody>" + |
| 28 | " <tr tabindex=\"0\">" + |
| 29 | " <th>corenlp</th>" + |
| 30 | " <th>p</th>" + |
| 31 | " <td>ART</td>" + |
| 32 | " <td>ADJA</td>" + |
| 33 | " <td>ADJA<br>ADJD</td>" + |
| 34 | " <td>NN</td>" + |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 35 | " <td>ADV</td>" + |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 36 | " </tr>" + |
| 37 | " <tr tabindex=\"0\">" + |
| 38 | " <th>opennlp</th>" + |
| 39 | " <th>p</th>" + |
| 40 | " <td>ART</td>" + |
| 41 | " <td>ADJA</td>" + |
| 42 | " <td></td>" + |
| 43 | " <td>NN</td>" + |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 44 | " <td>ADV</td>" + |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 45 | " </tr>" + |
| 46 | " </tbody>" + |
| 47 | " </table>" + |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 48 | " </div>"; |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 49 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 50 | var info = document.createElement('div'); |
| 51 | info.appendChild(table); |
| 52 | return table; |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 53 | }; |
| 54 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 55 | function matchTableComplexFactory () { |
| 56 | var table = document.createElement('div'); |
| 57 | table.className = 'matchtable'; |
| 58 | table.innerHTML = |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 59 | " <table>" + |
| 60 | " <thead>" + |
| 61 | " <tr>" + |
| 62 | " <th>Foundry</th>" + |
| 63 | " <th>Layer</th>" + |
| 64 | " <th>Der</th>" + |
| 65 | " <th>älteste</th>" + |
| 66 | " <th>lebende</th>" + |
Akron | aeeb825 | 2018-09-19 18:51:00 +0200 | [diff] [blame] | 67 | " <th class=\"mark\">Baum</th>" + |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 68 | " </tr>" + |
| 69 | " </thead>" + |
| 70 | " <tbody>" + |
| 71 | " <tr tabindex=\"0\">" + |
| 72 | " <th>corenlp</th>" + |
| 73 | " <th>p</th>" + |
| 74 | " <td>ART</td>" + |
| 75 | " <td>ADJA</td>" + |
| 76 | " <td>ADJA<br>ADJD</td>" + |
Akron | aeeb825 | 2018-09-19 18:51:00 +0200 | [diff] [blame] | 77 | " <td class=\"matchkeyvalues mark\">" + |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 78 | " <div>case:nom</div>" + |
| 79 | " <div>gender:masc<br/>gender:fem</div>" + |
| 80 | " <div>number:sg</div>" + |
| 81 | " </td>" + |
| 82 | " </tr>" + |
| 83 | " <tr tabindex=\"0\">" + |
| 84 | " <th>opennlp</th>" + |
| 85 | " <th>p</th>" + |
| 86 | " <td class=\"matchkeyvalues\">" + |
| 87 | " <div>case:nom</div>" + |
| 88 | " <div>gender:masc</div>" + |
| 89 | " <div>number:sg</div>" + |
Akron | 72245b6 | 2018-07-23 10:59:08 +0200 | [diff] [blame] | 90 | " <div>morphemes:.::_SORSZ \\ZERO::NOM 'period::PUNCT'</div>" + |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 91 | " </td>" + |
| 92 | " <td>ADJA</td>" + |
| 93 | " <td></td>" + |
Akron | aeeb825 | 2018-09-19 18:51:00 +0200 | [diff] [blame] | 94 | " <td class=\"mark\">NN</td>" + |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 95 | " </tr>" + |
| 96 | " </tbody>" + |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 97 | " </table>"; |
| 98 | var info = document.createElement('div'); |
| 99 | info.appendChild(table); |
| 100 | return table; |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 101 | }; |
| 102 | |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 103 | |
| 104 | define(['match/querycreator'], function (qcClass) { |
| 105 | |
| 106 | describe('KorAP.QueryCreator', function () { |
| 107 | |
| 108 | it('should be initializable', function () { |
| 109 | expect( |
| 110 | function() { |
| 111 | qcClass.create() |
| 112 | } |
| 113 | ).toThrow(new Error("Missing parameters")); |
| 114 | |
| 115 | expect( |
| 116 | function() { |
| 117 | qcClass.create("Test") |
| 118 | } |
| 119 | ).toThrow(new Error("Requires element")); |
| 120 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 121 | expect(qcClass.create(matchTableFactory()).toString()).toEqual(""); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 122 | }); |
| 123 | |
| 124 | it('should listen to click events', function () { |
| 125 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 126 | var matchTable = matchTableFactory(); |
| 127 | var qc = qcClass.create(matchTable); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 128 | |
| 129 | // Nothing to show |
| 130 | expect(qc.toString()).toEqual(""); |
| 131 | expect(qc.shown()).toBe(false); |
| 132 | qc.show(); |
| 133 | expect(qc.shown()).toBe(false); |
| 134 | expect(qc.element().className).toEqual("queryfragment"); |
| 135 | |
| 136 | // Click on cell 0:0 "Foundry" |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 137 | var cell = matchTable.querySelector("thead > tr > th:first-child"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 138 | expect(cell.innerString()).toEqual("Foundry"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 139 | cell.click(); |
| 140 | expect(cell.classList.contains("chosen")).toBe(false); |
| 141 | expect(qc.toString()).toEqual(""); |
| 142 | expect(qc.shown()).toBe(false); |
| 143 | |
| 144 | // Click on cell 0:2 "Der" |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 145 | cell = matchTable.querySelector("thead > tr > th:nth-child(3)") |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 146 | expect(cell.innerString()).toEqual("Der"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 147 | cell.click(); |
| 148 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 149 | expect(qc.toString()).toEqual("[orth=Der]"); |
| 150 | expect(qc.shown()).toBeTruthy(); |
| 151 | |
| 152 | // Click on cell 0:2 "Der" again - to hide |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 153 | cell = matchTable.querySelector("thead > tr > th:nth-child(3)") |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 154 | expect(cell.innerString()).toEqual("Der"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 155 | cell.click(); |
| 156 | expect(cell.classList.contains("chosen")).toBe(false); |
| 157 | expect(qc.toString()).toEqual(""); |
| 158 | expect(qc.shown()).toBe(false); |
| 159 | }); |
| 160 | |
| 161 | it('should create tokens in arbitrary order', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 162 | var matchTable = matchTableFactory(); |
| 163 | var qc = qcClass.create(matchTable); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 164 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 165 | var cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 166 | expect(cell.innerString()).toEqual("ADJA"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 167 | cell.click(); |
| 168 | expect(qc.toString()).toEqual("[opennlp/p=ADJA]"); |
| 169 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 170 | cell = matchTable.querySelector("thead > tr > th:nth-child(4)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 171 | expect(cell.innerString()).toEqual("älteste"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 172 | cell.click(); |
| 173 | expect(qc.toString()).toEqual("[opennlp/p=ADJA & orth=älteste]"); |
| 174 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 175 | cell = matchTable.querySelector("tbody > tr > td:nth-child(4)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 176 | expect(cell.innerString()).toEqual("ADJA"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 177 | cell.click(); |
| 178 | expect(qc.toString()).toEqual("[corenlp/p=ADJA & opennlp/p=ADJA & orth=älteste]"); |
| 179 | }); |
| 180 | |
| 181 | it('should create token sequences in arbitrary order', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 182 | var matchTable = matchTableFactory(); |
| 183 | var qc = qcClass.create(matchTable); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 184 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 185 | var cell = matchTable.querySelector("thead > tr > th:nth-child(5)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 186 | expect(cell.innerString()).toEqual("lebende"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 187 | cell.click(); |
| 188 | expect(qc.toString()).toEqual("[orth=lebende]"); |
| 189 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 190 | cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(3)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 191 | expect(cell.innerString()).toEqual("ART"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 192 | cell.click(); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 193 | expect(qc.toString()).toEqual("[opennlp/p=ART][][orth=lebende]"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 194 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 195 | cell = matchTable.querySelector("tbody > tr > td:nth-child(4)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 196 | expect(cell.innerString()).toEqual("ADJA"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 197 | cell.click(); |
| 198 | expect(qc.toString()).toEqual("[opennlp/p=ART][corenlp/p=ADJA][orth=lebende]"); |
| 199 | }); |
| 200 | |
| 201 | it('should remove chosen elements again', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 202 | var matchTable = matchTableFactory(); |
| 203 | var qc = qcClass.create(matchTable); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 204 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 205 | var cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 206 | expect(cell.innerString()).toEqual("ADJA"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 207 | cell.click(); |
| 208 | expect(qc.toString()).toEqual("[opennlp/p=ADJA]"); |
| 209 | var cell1 = cell; |
| 210 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 211 | cell = matchTable.querySelector("thead > tr > th:nth-child(4)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 212 | expect(cell.innerString()).toEqual("älteste"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 213 | cell.click(); |
| 214 | expect(qc.toString()).toEqual("[opennlp/p=ADJA & orth=älteste]"); |
| 215 | var cell2 = cell; |
| 216 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 217 | cell = matchTable.querySelector("tbody > tr > td:nth-child(3)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 218 | expect(cell.innerString()).toEqual("ART"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 219 | cell.click(); |
| 220 | expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste]"); |
| 221 | var cell3 = cell; |
| 222 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 223 | cell = matchTable.querySelector("thead > tr > th:nth-child(6)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 224 | expect(cell.innerString()).toEqual("Baum"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 225 | cell.click(); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 226 | expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste][][orth=Baum]"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 227 | var cell4 = cell; |
| 228 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 229 | cell = matchTable.querySelector("thead > tr > th:nth-child(5)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 230 | expect(cell.innerString()).toEqual("lebende"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 231 | cell.click(); |
| 232 | expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste][orth=lebende][orth=Baum]"); |
| 233 | var cell5 = cell; |
| 234 | |
| 235 | |
| 236 | // Remove annotations again |
| 237 | expect(cell5.classList.contains("chosen")).toBeTruthy(); |
| 238 | cell5.click() |
| 239 | expect(cell5.classList.contains("chosen")).toBe(false); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 240 | expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA & orth=älteste][][orth=Baum]"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 241 | |
| 242 | expect(cell2.classList.contains("chosen")).toBeTruthy(); |
| 243 | cell2.click() |
| 244 | expect(cell2.classList.contains("chosen")).toBe(false); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 245 | expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA][][orth=Baum]"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 246 | |
| 247 | expect(cell1.classList.contains("chosen")).toBeTruthy(); |
| 248 | cell1.click() |
| 249 | expect(cell1.classList.contains("chosen")).toBe(false); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 250 | expect(qc.toString()).toEqual("[corenlp/p=ART][]{2}[orth=Baum]"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 251 | |
| 252 | // Re-add first cell at the same position |
| 253 | expect(cell1.classList.contains("chosen")).toBe(false); |
| 254 | cell1.click() |
| 255 | expect(cell1.classList.contains("chosen")).toBeTruthy(); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 256 | expect(qc.toString()).toEqual("[corenlp/p=ART][opennlp/p=ADJA][][orth=Baum]"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 257 | |
| 258 | expect(cell3.classList.contains("chosen")).toBeTruthy(); |
| 259 | cell3.click() |
| 260 | expect(cell3.classList.contains("chosen")).toBe(false); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 261 | expect(qc.toString()).toEqual("[opennlp/p=ADJA][][orth=Baum]"); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 262 | |
| 263 | expect(cell4.classList.contains("chosen")).toBeTruthy(); |
| 264 | cell4.click() |
| 265 | expect(cell4.classList.contains("chosen")).toBe(false); |
| 266 | expect(qc.toString()).toEqual("[opennlp/p=ADJA]"); |
| 267 | |
| 268 | // Remove last token |
| 269 | expect(qc.shown()).toBeTruthy(); |
| 270 | expect(qc.element().innerHTML).toEqual("<span>New Query:</span><span>[opennlp/p=ADJA]</span>"); |
| 271 | expect(cell1.classList.contains("chosen")).toBeTruthy(); |
| 272 | cell1.click() |
| 273 | expect(cell1.classList.contains("chosen")).toBe(false); |
| 274 | expect(qc.toString()).toEqual(""); |
| 275 | expect(qc.shown()).toBe(false); |
| 276 | |
| 277 | // Re-add token |
| 278 | expect(cell4.classList.contains("chosen")).toBe(false); |
| 279 | cell4.click() |
| 280 | expect(cell4.classList.contains("chosen")).toBeTruthy(); |
| 281 | expect(qc.toString()).toEqual("[orth=Baum]"); |
| 282 | expect(qc.shown()).toBeTruthy(); |
| 283 | expect(qc.element().innerHTML).toEqual("<span>New Query:</span><span>[orth=Baum]</span>"); |
| 284 | }); |
| 285 | |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 286 | it('should ignore empty terms', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 287 | var matchTable = matchTableFactory(); |
| 288 | var qc = qcClass.create(matchTable); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 289 | |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 290 | // Nothing to show |
| 291 | expect(qc.toString()).toEqual(""); |
| 292 | expect(qc.shown()).toBe(false); |
| 293 | qc.show(); |
| 294 | expect(qc.shown()).toBe(false); |
| 295 | expect(qc.element().className).toEqual("queryfragment"); |
| 296 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 297 | var cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(4)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 298 | expect(cell.innerString()).toEqual("ADJA"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 299 | expect(cell.classList.contains("chosen")).toBe(false); |
| 300 | cell.click(); |
| 301 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 302 | expect(qc.toString()).toEqual("[opennlp/p=ADJA]"); |
| 303 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 304 | cell = matchTable.querySelector("tbody > tr:nth-child(2) > td:nth-child(5)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 305 | expect(cell.innerString()).toEqual(""); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 306 | expect(cell.classList.contains("chosen")).toBe(false); |
| 307 | cell.click(); |
| 308 | expect(cell.classList.contains("chosen")).toBe(false); |
| 309 | expect(qc.toString()).toEqual("[opennlp/p=ADJA]"); |
| 310 | |
| 311 | }); |
| 312 | |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 313 | it('should create or-groups for alternative terms', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 314 | var matchTable = matchTableFactory(); |
| 315 | var qc = qcClass.create(matchTable); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 316 | |
| 317 | // Nothing to show |
| 318 | expect(qc.toString()).toEqual(""); |
| 319 | expect(qc.shown()).toBe(false); |
| 320 | qc.show(); |
| 321 | expect(qc.shown()).toBe(false); |
| 322 | expect(qc.element().className).toEqual("queryfragment"); |
| 323 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 324 | var cell = matchTable.querySelector("thead > tr > th:nth-child(5)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 325 | expect(cell.innerString()).toEqual("lebende"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 326 | expect(cell.classList.contains("chosen")).toBe(false); |
| 327 | cell.click(); |
| 328 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 329 | expect(qc.toString()).toEqual("[orth=lebende]"); |
| 330 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 331 | cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(5)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 332 | expect(cell.innerString()).toEqual("ADJAADJD"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 333 | expect(cell.classList.contains("chosen")).toBe(false); |
| 334 | cell.click(); |
| 335 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 336 | expect(qc.toString()).toEqual("[(corenlp/p=ADJA | corenlp/p=ADJD) & orth=lebende]"); |
| 337 | |
| 338 | // Remove or group again |
| 339 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 340 | cell.click(); |
| 341 | expect(cell.classList.contains("chosen")).toBe(false); |
| 342 | expect(qc.toString()).toEqual("[orth=lebende]"); |
| 343 | }); |
| 344 | |
| 345 | |
| 346 | it('should add whole rows', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 347 | var matchTable = matchTableFactory(); |
| 348 | var qc = qcClass.create(matchTable); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 349 | |
| 350 | // Nothing to show |
| 351 | expect(qc.toString()).toEqual(""); |
| 352 | expect(qc.shown()).toBe(false); |
| 353 | qc.show(); |
| 354 | expect(qc.shown()).toBe(false); |
| 355 | expect(qc.element().className).toEqual("queryfragment"); |
| 356 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 357 | var corenlpRow = matchTable.querySelector("tbody > tr:nth-child(1)"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 358 | |
| 359 | var cell = corenlpRow.querySelector("td:nth-child(4)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 360 | expect(cell.innerString()).toEqual("ADJA"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 361 | expect(cell.classList.contains("chosen")).toBe(false); |
| 362 | cell.click(); |
| 363 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 364 | |
| 365 | // Activate another cell in another row |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 366 | cell = matchTable.querySelector("tbody > tr:nth-child(2) td:nth-child(3)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 367 | expect(cell.innerString()).toEqual("ART"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 368 | expect(cell.classList.contains("chosen")).toBe(false); |
| 369 | cell.click(); |
| 370 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 371 | |
| 372 | expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeNull(); |
| 373 | expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy(); |
| 374 | expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeNull(); |
| 375 | expect(corenlpRow.querySelector("td:nth-child(6).chosen")).toBeNull(); |
| 376 | |
| 377 | expect(qc.toString()).toEqual("[opennlp/p=ART][corenlp/p=ADJA]"); |
| 378 | |
| 379 | // Mark all corenlp lists |
| 380 | cell = corenlpRow.querySelector("th:nth-child(1)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 381 | expect(cell.innerString()).toEqual("corenlp"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 382 | expect(cell.classList.contains("chosen")).toBe(false); |
| 383 | cell.click(); |
| 384 | expect(cell.classList.contains("chosen")).toBe(false); |
| 385 | |
| 386 | expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeTruthy(); |
| 387 | expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy(); |
| 388 | expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeTruthy(); |
| 389 | expect(corenlpRow.querySelector("td:nth-child(6).chosen")).toBeTruthy(); |
| 390 | |
| 391 | // Replay the choice without any effect |
| 392 | cell = corenlpRow.querySelector("th:nth-child(1)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 393 | expect(cell.innerString()).toEqual("corenlp"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 394 | expect(cell.classList.contains("chosen")).toBe(false); |
| 395 | cell.click(); |
| 396 | expect(cell.classList.contains("chosen")).toBe(false); |
| 397 | |
| 398 | expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeTruthy(); |
| 399 | expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy(); |
| 400 | expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeTruthy(); |
| 401 | expect(corenlpRow.querySelector("td:nth-child(6).chosen")).toBeTruthy(); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 402 | expect(corenlpRow.querySelector("td:nth-child(7).chosen")).toBeTruthy(); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 403 | |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 404 | expect(qc.toString()).toEqual("[corenlp/p=ART & opennlp/p=ART][corenlp/p=ADJA][(corenlp/p=ADJA | corenlp/p=ADJD)][corenlp/p=NN][corenlp/p=ADV]"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 405 | |
| 406 | // Remove one of the cells again |
| 407 | cell = corenlpRow.querySelector("td:nth-child(5).chosen"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 408 | expect(cell.innerString()).toEqual("ADJAADJD"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 409 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 410 | cell.click(); |
| 411 | expect(cell.classList.contains("chosen")).toBe(false); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 412 | expect(qc.toString()).toEqual("[corenlp/p=ART & opennlp/p=ART][corenlp/p=ADJA][][corenlp/p=NN][corenlp/p=ADV]"); |
Akron | c8461bf | 2017-06-29 15:05:24 +0200 | [diff] [blame] | 413 | |
| 414 | }); |
Akron | 8084cb5 | 2017-06-29 17:11:14 +0200 | [diff] [blame] | 415 | |
| 416 | it('should ignore empty terms in whole rows', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 417 | var matchTable = matchTableFactory(); |
| 418 | var qc = qcClass.create(matchTable); |
Akron | 8084cb5 | 2017-06-29 17:11:14 +0200 | [diff] [blame] | 419 | expect(qc.toString()).toEqual(""); |
| 420 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 421 | var opennlpRow = matchTable.querySelector("tbody > tr:nth-child(2)"); |
Akron | 8084cb5 | 2017-06-29 17:11:14 +0200 | [diff] [blame] | 422 | |
| 423 | expect(opennlpRow.querySelector("td:nth-child(3).chosen")).toBeNull(); |
| 424 | expect(opennlpRow.querySelector("td:nth-child(4).chosen")).toBeNull(); |
| 425 | expect(opennlpRow.querySelector("td:nth-child(5).chosen")).toBeNull(); |
| 426 | expect(opennlpRow.querySelector("td:nth-child(6).chosen")).toBeNull(); |
| 427 | |
| 428 | expect(qc.toString()).toEqual(""); |
| 429 | |
| 430 | // Mark all opennlp lists |
| 431 | cell = opennlpRow.querySelector("th:nth-child(1)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 432 | expect(cell.innerString()).toEqual("opennlp"); |
Akron | 8084cb5 | 2017-06-29 17:11:14 +0200 | [diff] [blame] | 433 | expect(cell.classList.contains("chosen")).toBe(false); |
| 434 | cell.click(); |
| 435 | expect(cell.classList.contains("chosen")).toBe(false); |
| 436 | |
| 437 | expect(opennlpRow.querySelector("td:nth-child(3).chosen")).toBeTruthy(); |
| 438 | expect(opennlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy(); |
| 439 | expect(opennlpRow.querySelector("td:nth-child(5).chosen")).toBeNull(); |
| 440 | expect(opennlpRow.querySelector("td:nth-child(6).chosen")).toBeTruthy(); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 441 | |
| 442 | expect(qc.toString()).toEqual("[opennlp/p=ART][opennlp/p=ADJA][][opennlp/p=NN][opennlp/p=ADV]"); |
Akron | 8084cb5 | 2017-06-29 17:11:14 +0200 | [diff] [blame] | 443 | }); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 444 | |
| 445 | it('should support multiple distances', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 446 | var matchTable = matchTableFactory(); |
| 447 | var qc = qcClass.create(matchTable); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 448 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 449 | var cell = matchTable.querySelector("thead > tr > th:nth-child(3)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 450 | expect(cell.innerString()).toEqual("Der"); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 451 | cell.click(); |
| 452 | expect(qc.toString()).toEqual("[orth=Der]"); |
| 453 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 454 | cell = matchTable.querySelector("thead > tr > th:nth-child(7)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 455 | expect(cell.innerString()).toEqual("hier"); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 456 | cell.click(); |
| 457 | expect(qc.toString()).toEqual("[orth=Der][]{3}[orth=hier]"); |
| 458 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 459 | cell = matchTable.querySelector("thead > tr > th:nth-child(5)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 460 | expect(cell.innerString()).toEqual("lebende"); |
Akron | e9be11d | 2017-06-29 20:10:58 +0200 | [diff] [blame] | 461 | cell.click(); |
| 462 | expect(qc.toString()).toEqual("[orth=Der][][orth=lebende][][orth=hier]"); |
| 463 | }); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 464 | |
| 465 | it('should create and-groups for key-value terms', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 466 | var matchTable = matchTableComplexFactory(); |
| 467 | var qc = qcClass.create(matchTable); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 468 | |
| 469 | // Nothing to show |
| 470 | expect(qc.toString()).toEqual(""); |
| 471 | expect(qc.shown()).toBe(false); |
| 472 | qc.show(); |
| 473 | expect(qc.shown()).toBe(false); |
| 474 | expect(qc.element().className).toEqual("queryfragment"); |
| 475 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 476 | var cell = matchTable.querySelector("thead > tr > th:nth-child(5)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 477 | expect(cell.innerString()).toEqual("lebende"); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 478 | expect(cell.classList.contains("chosen")).toBe(false); |
| 479 | cell.click(); |
| 480 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 481 | expect(qc.toString()).toEqual("[orth=lebende]"); |
| 482 | |
| 483 | // Check complex cell |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 484 | cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(6)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 485 | expect(cell.innerString()).toMatch(/case:nom/); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 486 | expect(cell.classList.contains("chosen")).toBe(false); |
| 487 | cell.click(); |
| 488 | expect(cell.classList.contains("chosen")).toBe(false); |
| 489 | expect(qc.toString()).toEqual("[orth=lebende]"); |
| 490 | |
| 491 | // Check complex cell div |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 492 | cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(1)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 493 | expect(cell.innerString()).toEqual('case:nom'); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 494 | expect(cell.classList.contains("chosen")).toBe(false); |
| 495 | cell.click(); |
| 496 | expect(cell.classList.contains("chosen")).toBe(true); |
| 497 | expect(qc.toString()).toEqual("[orth=lebende][corenlp/p=case:nom]"); |
| 498 | var cell = cell; |
| 499 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 500 | cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(3)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 501 | expect(cell.innerString()).toEqual('number:sg'); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 502 | expect(cell.classList.contains("chosen")).toBe(false); |
| 503 | cell.click(); |
| 504 | expect(cell.classList.contains("chosen")).toBe(true); |
| 505 | expect(qc.toString()).toEqual("[orth=lebende][corenlp/p=case:nom & corenlp/p=number:sg]"); |
| 506 | var cell2 = cell; |
| 507 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 508 | cell = matchTable.querySelector("tbody > tr:nth-child(1) > td:nth-child(6) > div:nth-child(2)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 509 | expect(cell.innerString()).toEqual('gender:mascgender:fem'); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 510 | expect(cell.classList.contains("chosen")).toBe(false); |
| 511 | cell.click(); |
| 512 | expect(cell.classList.contains("chosen")).toBe(true); |
| 513 | expect(qc.toString()).toEqual("[orth=lebende][(corenlp/p=gender:fem | corenlp/p=gender:masc) & corenlp/p=case:nom & corenlp/p=number:sg]"); |
| 514 | var cell3 = cell; |
| 515 | |
| 516 | // Remove cell again |
| 517 | cell = cell2; |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 518 | expect(cell.innerString()).toEqual('number:sg'); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 519 | expect(cell.classList.contains("chosen")).toBe(true); |
| 520 | cell.click(); |
| 521 | expect(cell.classList.contains("chosen")).toBe(false); |
| 522 | expect(qc.toString()).toEqual("[orth=lebende][(corenlp/p=gender:fem | corenlp/p=gender:masc) & corenlp/p=case:nom]"); |
| 523 | |
| 524 | // Remove cell again |
| 525 | cell = cell3; |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 526 | expect(cell.innerString()).toEqual('gender:mascgender:fem'); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 527 | expect(cell.classList.contains("chosen")).toBe(true); |
| 528 | cell.click(); |
| 529 | expect(cell.classList.contains("chosen")).toBe(false); |
| 530 | expect(qc.toString()).toEqual("[orth=lebende][corenlp/p=case:nom]"); |
| 531 | }); |
| 532 | |
| 533 | |
| 534 | it('should create rows including key-value terms', function () { |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 535 | var matchTable = matchTableComplexFactory(); |
| 536 | var qc = qcClass.create(matchTable); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 537 | expect(qc.toString()).toEqual(""); |
| 538 | |
Akron | 70903c4 | 2018-02-05 12:31:10 +0100 | [diff] [blame] | 539 | var corenlpRow = matchTable.querySelector("tbody > tr:nth-child(1)"); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 540 | |
| 541 | expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeNull(); |
| 542 | expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeNull(); |
| 543 | expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeNull(); |
| 544 | expect(corenlpRow.querySelector("td:nth-child(6) *.chosen")).toBeNull(); |
| 545 | |
| 546 | expect(qc.toString()).toEqual(""); |
| 547 | |
| 548 | // Mark all opennlp lists |
| 549 | cell = corenlpRow.querySelector("th:nth-child(1)"); |
Akron | bdcbbf4 | 2018-04-25 12:42:44 +0200 | [diff] [blame] | 550 | expect(cell.innerString()).toEqual("corenlp"); |
Akron | 7cf33fd | 2017-07-03 17:33:39 +0200 | [diff] [blame] | 551 | expect(cell.classList.contains("chosen")).toBe(false); |
| 552 | cell.click(); |
| 553 | expect(cell.classList.contains("chosen")).toBe(false); |
| 554 | |
| 555 | expect(corenlpRow.querySelector("td:nth-child(3).chosen")).toBeTruthy(); |
| 556 | expect(corenlpRow.querySelector("td:nth-child(4).chosen")).toBeTruthy(); |
| 557 | expect(corenlpRow.querySelector("td:nth-child(5).chosen")).toBeTruthy(); |
| 558 | expect(corenlpRow.querySelector("td:nth-child(6) div:nth-child(1).chosen")).toBeTruthy(); |
| 559 | expect(corenlpRow.querySelector("td:nth-child(6) div:nth-child(2).chosen")).toBeTruthy(); |
| 560 | expect(corenlpRow.querySelector("td:nth-child(6) div:nth-child(3).chosen")).toBeTruthy(); |
| 561 | |
| 562 | expect(qc.toString()).toEqual( |
| 563 | "[corenlp/p=ART]"+ |
| 564 | "[corenlp/p=ADJA]"+ |
| 565 | "[(corenlp/p=ADJA | corenlp/p=ADJD)]"+ |
| 566 | "[(corenlp/p=gender:fem | corenlp/p=gender:masc) & corenlp/p=case:nom & corenlp/p=number:sg]" |
| 567 | ); |
| 568 | }); |
Akron | 72245b6 | 2018-07-23 10:59:08 +0200 | [diff] [blame] | 569 | |
| 570 | it('should support verbatim strings', function () { |
| 571 | var matchTable = matchTableComplexFactory(); |
| 572 | var qc = qcClass.create(matchTable); |
| 573 | expect(qc.toString()).toEqual(""); |
| 574 | |
| 575 | // TODO: |
| 576 | // This does not respect keys vs values at the moment, but neither does Koral |
| 577 | var cell = matchTable.querySelector("tbody > tr:nth-child(2) > td > div:nth-child(4)"); |
| 578 | expect(cell.innerString()).toEqual("morphemes:.::_SORSZ \\ZERO::NOM 'period::PUNCT'"); |
| 579 | expect(cell.classList.contains("chosen")).toBe(false); |
| 580 | cell.click(); |
| 581 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 582 | expect(qc.toString()).toEqual("[opennlp/p='morphemes:.::_SORSZ \\\\ZERO::NOM \\\'period::PUNCT\\\'']"); |
| 583 | }); |
Akron | aeeb825 | 2018-09-19 18:51:00 +0200 | [diff] [blame] | 584 | |
| 585 | it('should respect marked elements', function () { |
| 586 | var matchTable = matchTableComplexFactory(); |
| 587 | var qc = qcClass.create(matchTable); |
| 588 | expect(qc.toString()).toEqual(""); |
| 589 | |
| 590 | var cell = matchTable.querySelector("thead > tr > th:nth-child(6)"); |
| 591 | expect(cell.classList.contains("mark")).toBeTruthy(); |
| 592 | expect(cell.classList.contains("chosen")).toBeFalsy(); |
| 593 | |
| 594 | cell.click(); |
| 595 | expect(cell.classList.contains("mark")).toBeTruthy(); |
| 596 | expect(cell.classList.contains("chosen")).toBeTruthy(); |
| 597 | |
| 598 | cell.click(); |
| 599 | expect(cell.classList.contains("mark")).toBeTruthy(); |
| 600 | expect(cell.classList.contains("chosen")).toBeFalsy(); |
| 601 | }); |
Akron | b46d8e3 | 2017-06-29 14:26:14 +0200 | [diff] [blame] | 602 | }); |
| 603 | }); |