test.filters.js (69780B)
1 describe("Filters", function() { 2 describe("GetVocabFilters method", function() { 3 it("Should correctly filter vocab for All Definitions", function() { 4 // Initialize expected 5 let expected = [ 6 {outputIndex:0, inputIndex:1, filters:[{index:2, value:".*"}, {index:3, value:"Colors"}]}, 7 {outputIndex:1, inputIndex:0, filters:[{index:2, value:".*"}, {index:3, value:"Colors"}]}, 8 ]; 9 10 // Filter vocab 11 let actual = GetVocabFilters([{category:"Colors", type:"All Types", direction:"Eng. ↔ Esp."}]); 12 13 // Assert filtered vocab is correct 14 expect(actual).to.have.deep.members(expected); 15 }); 16 17 it("Should correctly filter vocab for multiple filters", function() { 18 // Initialize expected 19 let expected = [ 20 {outputIndex:0, inputIndex:1, filters:[{index:2, value:".*"}, {index:3, value:"Colors"}]}, 21 {outputIndex:1, inputIndex:0, filters:[{index:2, value:".*"}, {index:3, value:"Colors"}]}, 22 {outputIndex:1, inputIndex:0, filters:[{index:2, value:"Verb"}, {index:3, value:"Months"}]}, 23 ]; 24 25 // Filter vocab 26 let actual = GetVocabFilters([ 27 {category:"Colors", type:"All Types", direction:"Eng. ↔ Esp."}, 28 {category:"Months", type:"Verbs", direction:"Esp. → Eng."}, 29 ]); 30 31 // Assert filtered vocab is correct 32 expect(actual).to.have.deep.members(expected); 33 }); 34 35 describe("Direction filters", function() { 36 it("Should correctly filter vocab for English to Spanish", function() { 37 // Initialize expected 38 let expected = [ 39 {outputIndex:0, inputIndex:1, filters:[{index:2, value:".*"}, {index:3, value:"Colors"}]}, 40 ]; 41 42 // Filter vocab 43 let actual = GetVocabFilters([{category:"Colors", type:"All Types", direction:"Eng. → Esp."}]); 44 45 // Assert filtered vocab is correct 46 expect(actual).to.have.deep.members(expected); 47 }); 48 49 it("Should correctly filter vocab for Spanish to English", function() { 50 // Initialize expected 51 let expected = [ 52 {outputIndex:1, inputIndex:0, filters:[{index:2, value:".*"}, {index:3, value:"Colors"}]}, 53 ]; 54 55 // Filter vocab 56 let actual = GetVocabFilters([{category:"Colors", type:"All Types", direction:"Esp. → Eng."}]); 57 58 // Assert filtered vocab is correct 59 expect(actual).to.have.deep.members(expected); 60 }); 61 }); 62 63 describe("Word Type filters", function() { 64 it("Should correctly filter vocab for Nouns", function() { 65 // Initialize expected 66 let expected = [ 67 {outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun"}, {index:3, value:"Colors"}]}, 68 {outputIndex:1, inputIndex:0, filters:[{index:2, value:"Noun"}, {index:3, value:"Colors"}]}, 69 ]; 70 71 // Filter vocab 72 let actual = GetVocabFilters([{category:"Colors", type:"Nouns", direction:"Eng. ↔ Esp."}]); 73 74 // Assert filtered vocab is correct 75 expect(actual).to.have.deep.members(expected); 76 }); 77 78 it("Should correctly filter vocab for Adjectives", function() { 79 // Initialize expected 80 let expected = [ 81 {outputIndex:0, inputIndex:1, filters:[{index:2, value:"Adjective"}, {index:3, value:"Colors"}]}, 82 {outputIndex:1, inputIndex:0, filters:[{index:2, value:"Adjective"}, {index:3, value:"Colors"}]}, 83 ]; 84 85 // Filter vocab 86 let actual = GetVocabFilters([{category:"Colors", type:"Adjectives", direction:"Eng. ↔ Esp."}]); 87 88 // Assert filtered vocab is correct 89 expect(actual).to.have.deep.members(expected); 90 }); 91 92 it("Should correctly filter vocab for Verbs", function() { 93 // Initialize expected 94 let expected = [ 95 {outputIndex:0, inputIndex:1, filters:[{index:2, value:"Verb"}, {index:3, value:"Colors"}]}, 96 {outputIndex:1, inputIndex:0, filters:[{index:2, value:"Verb"}, {index:3, value:"Colors"}]}, 97 ]; 98 99 // Filter vocab 100 let actual = GetVocabFilters([{category:"Colors", type:"Verbs", direction:"Eng. ↔ Esp."}]); 101 102 // Assert filtered vocab is correct 103 expect(actual).to.have.deep.members(expected); 104 }); 105 106 it("Should throw error for unknown word type", function() { 107 expect(() => GetVocabFilters([{category:"Colors", type:"test", direction:"Eng. ↔ Esp."}])).to.throw() 108 expect(() => GetVocabFilters([{category:"Colors", type:"", direction:"Eng. ↔ Esp."}])).to.throw() 109 expect(() => GetVocabFilters([{category:"Colors", type:1, direction:"Eng. ↔ Esp."}])).to.throw() 110 expect(() => GetVocabFilters([{category:"Colors", type:null, direction:"Eng. ↔ Esp."}])).to.throw() 111 }); 112 }); 113 }); 114 115 describe("GetVerbFilters method", function() { 116 it("Should correctly filter verbs for All Conjugations", function() { 117 // Initialize expected 118 let expected = [ 119 {outputIndex:0, inputIndex:03, filters:[{index:02, value:".*"}]}, 120 {outputIndex:0, inputIndex:05, filters:[{index:04, value:".*"}]}, 121 {outputIndex:0, inputIndex:07, filters:[{index:06, value:".*"}]}, 122 {outputIndex:0, inputIndex:08, filters:[{index:06, value:".*"}]}, 123 {outputIndex:0, inputIndex:09, filters:[{index:06, value:".*"}]}, 124 {outputIndex:0, inputIndex:10, filters:[{index:06, value:".*"}]}, 125 {outputIndex:0, inputIndex:11, filters:[{index:06, value:".*"}]}, 126 {outputIndex:0, inputIndex:13, filters:[{index:12, value:".*"}]}, 127 {outputIndex:0, inputIndex:14, filters:[{index:12, value:".*"}]}, 128 {outputIndex:0, inputIndex:15, filters:[{index:12, value:".*"}]}, 129 {outputIndex:0, inputIndex:16, filters:[{index:12, value:".*"}]}, 130 {outputIndex:0, inputIndex:17, filters:[{index:12, value:".*"}]}, 131 {outputIndex:0, inputIndex:19, filters:[{index:18, value:".*"}]}, 132 {outputIndex:0, inputIndex:20, filters:[{index:18, value:".*"}]}, 133 {outputIndex:0, inputIndex:21, filters:[{index:18, value:".*"}]}, 134 {outputIndex:0, inputIndex:22, filters:[{index:18, value:".*"}]}, 135 {outputIndex:0, inputIndex:23, filters:[{index:18, value:".*"}]}, 136 {outputIndex:0, inputIndex:25, filters:[{index:24, value:".*"}]}, 137 {outputIndex:0, inputIndex:26, filters:[{index:24, value:".*"}]}, 138 {outputIndex:0, inputIndex:27, filters:[{index:24, value:".*"}]}, 139 {outputIndex:0, inputIndex:28, filters:[{index:24, value:".*"}]}, 140 {outputIndex:0, inputIndex:29, filters:[{index:24, value:".*"}]}, 141 {outputIndex:0, inputIndex:31, filters:[{index:30, value:".*"}]}, 142 {outputIndex:0, inputIndex:32, filters:[{index:30, value:".*"}]}, 143 {outputIndex:0, inputIndex:33, filters:[{index:30, value:".*"}]}, 144 {outputIndex:0, inputIndex:34, filters:[{index:30, value:".*"}]}, 145 {outputIndex:0, inputIndex:35, filters:[{index:30, value:".*"}]}, 146 {outputIndex:0, inputIndex:37, filters:[{index:36, value:".*"}]}, 147 {outputIndex:0, inputIndex:38, filters:[{index:36, value:".*"}]}, 148 {outputIndex:0, inputIndex:39, filters:[{index:36, value:".*"}]}, 149 {outputIndex:0, inputIndex:40, filters:[{index:36, value:".*"}]}, 150 {outputIndex:0, inputIndex:41, filters:[{index:36, value:".*"}]}, 151 {outputIndex:0, inputIndex:43, filters:[{index:42, value:".*"}]}, 152 {outputIndex:0, inputIndex:44, filters:[{index:42, value:".*"}]}, 153 {outputIndex:0, inputIndex:45, filters:[{index:42, value:".*"}]}, 154 {outputIndex:0, inputIndex:46, filters:[{index:42, value:".*"}]}, 155 {outputIndex:0, inputIndex:47, filters:[{index:42, value:".*"}]}, 156 ]; 157 158 // Filter verbs 159 let actual = GetVerbFilters([{tense:"all tenses", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 160 161 // Assert filtered verbs are correct 162 expect(actual).to.have.deep.members(expected); 163 }); 164 165 it("Should correctly filter verbs for multiple filters", function() { 166 // Initialize expected 167 let expected = [ 168 {outputIndex:0, inputIndex:03, filters:[{index:02, value:"Irregular|Stem Changing|Orthographic"}]}, 169 {outputIndex:0, inputIndex:05, filters:[{index:04, value:"Irregular|Stem Changing|Orthographic"}]}, 170 {outputIndex:0, inputIndex:07, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 171 {outputIndex:0, inputIndex:08, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 172 {outputIndex:0, inputIndex:09, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 173 {outputIndex:0, inputIndex:10, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 174 {outputIndex:0, inputIndex:11, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 175 {outputIndex:0, inputIndex:13, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 176 {outputIndex:0, inputIndex:14, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 177 {outputIndex:0, inputIndex:15, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 178 {outputIndex:0, inputIndex:16, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 179 {outputIndex:0, inputIndex:17, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 180 {outputIndex:0, inputIndex:19, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 181 {outputIndex:0, inputIndex:20, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 182 {outputIndex:0, inputIndex:21, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 183 {outputIndex:0, inputIndex:22, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 184 {outputIndex:0, inputIndex:23, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 185 {outputIndex:0, inputIndex:25, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 186 {outputIndex:0, inputIndex:26, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 187 {outputIndex:0, inputIndex:27, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 188 {outputIndex:0, inputIndex:28, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 189 {outputIndex:0, inputIndex:29, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 190 {outputIndex:0, inputIndex:31, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 191 {outputIndex:0, inputIndex:32, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 192 {outputIndex:0, inputIndex:33, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 193 {outputIndex:0, inputIndex:34, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 194 {outputIndex:0, inputIndex:35, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 195 {outputIndex:0, inputIndex:37, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 196 {outputIndex:0, inputIndex:38, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 197 {outputIndex:0, inputIndex:39, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 198 {outputIndex:0, inputIndex:40, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 199 {outputIndex:0, inputIndex:41, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 200 {outputIndex:0, inputIndex:43, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 201 {outputIndex:0, inputIndex:44, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 202 {outputIndex:0, inputIndex:45, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 203 {outputIndex:0, inputIndex:46, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 204 {outputIndex:0, inputIndex:47, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 205 206 {outputIndex:0, inputIndex:07, filters:[{index:06, value:".*"}]}, 207 {outputIndex:0, inputIndex:08, filters:[{index:06, value:".*"}]}, 208 {outputIndex:0, inputIndex:09, filters:[{index:06, value:".*"}]}, 209 {outputIndex:0, inputIndex:10, filters:[{index:06, value:".*"}]}, 210 {outputIndex:0, inputIndex:11, filters:[{index:06, value:".*"}]}, 211 212 {outputIndex:03, inputIndex:1, filters:[{index:02, value:"Stem Changing"}]}, 213 {outputIndex:05, inputIndex:1, filters:[{index:04, value:"Stem Changing"}]}, 214 {outputIndex:10, inputIndex:1, filters:[{index:06, value:"Stem Changing"}]}, 215 {outputIndex:16, inputIndex:1, filters:[{index:12, value:"Stem Changing"}]}, 216 {outputIndex:22, inputIndex:1, filters:[{index:18, value:"Stem Changing"}]}, 217 {outputIndex:28, inputIndex:1, filters:[{index:24, value:"Stem Changing"}]}, 218 {outputIndex:34, inputIndex:1, filters:[{index:30, value:"Stem Changing"}]}, 219 {outputIndex:40, inputIndex:1, filters:[{index:36, value:"Stem Changing"}]}, 220 {outputIndex:46, inputIndex:1, filters:[{index:42, value:"Stem Changing"}]}, 221 ]; 222 223 // Filter verbs 224 let actual = GetVerbFilters([ 225 { tense:"all tenses", subject:"all subjects", type:"Nonregular", direction:"Eng. => Conj." }, 226 { tense:"present tense", subject:"all subjects", type:"all types", direction:"Eng. => Conj." }, 227 { tense:"all tenses", subject:"nosotros", type:"stem changing", direction:"Conj. => Esp." } 228 ]); 229 230 // Assert filtered verbs are correct 231 expect(actual).to.have.deep.members(expected); 232 }); 233 234 describe("Tense filters", function() { 235 it("Should correctly filter verbs for Present Participles", function() { 236 // Initialize expected 237 let expected = [ 238 {outputIndex:0, inputIndex:3, filters:[{index:2, value:".*"}]}, 239 ]; 240 241 // Filter verbs 242 let actual = GetVerbFilters([{tense:"Present Participles", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 243 244 // Assert filtered verbs are correct 245 expect(actual).to.have.deep.members(expected); 246 }); 247 248 it("Should correctly filter verbs for Past Participles", function() { 249 // Initialize expected 250 let expected = [ 251 {outputIndex:0, inputIndex:5, filters:[{index:4, value:".*"}]}, 252 ]; 253 254 // Filter verbs 255 let actual = GetVerbFilters([{tense:"Past Participles", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 256 257 // Assert filtered verbs are correct 258 expect(actual).to.have.deep.members(expected); 259 }); 260 261 it("Should correctly filter verbs for Present Tense", function() { 262 // Initialize expected 263 let expected = [ 264 {outputIndex:0, inputIndex:07, filters:[{index:6, value:".*"}]}, 265 {outputIndex:0, inputIndex:08, filters:[{index:6, value:".*"}]}, 266 {outputIndex:0, inputIndex:09, filters:[{index:6, value:".*"}]}, 267 {outputIndex:0, inputIndex:10, filters:[{index:6, value:".*"}]}, 268 {outputIndex:0, inputIndex:11, filters:[{index:6, value:".*"}]}, 269 ]; 270 271 // Filter verbs 272 let actual = GetVerbFilters([{tense:"Present Tense", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 273 274 // Assert filtered verbs are correct 275 expect(actual).to.have.deep.members(expected); 276 }); 277 278 it("Should correctly filter verbs for Preterite Tense", function() { 279 // Initialize expected 280 let expected = [ 281 {outputIndex:0, inputIndex:13, filters:[{index:12, value:".*"}]}, 282 {outputIndex:0, inputIndex:14, filters:[{index:12, value:".*"}]}, 283 {outputIndex:0, inputIndex:15, filters:[{index:12, value:".*"}]}, 284 {outputIndex:0, inputIndex:16, filters:[{index:12, value:".*"}]}, 285 {outputIndex:0, inputIndex:17, filters:[{index:12, value:".*"}]}, 286 ]; 287 288 // Filter verbs 289 let actual = GetVerbFilters([{tense:"Preterite Tense", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 290 291 // Assert filtered verbs are correct 292 expect(actual).to.have.deep.members(expected); 293 }); 294 295 it("Should correctly filter verbs for Imperfect Tense", function() { 296 // Initialize expected 297 let expected = [ 298 {outputIndex:0, inputIndex:19, filters:[{index:18, value:".*"}]}, 299 {outputIndex:0, inputIndex:20, filters:[{index:18, value:".*"}]}, 300 {outputIndex:0, inputIndex:21, filters:[{index:18, value:".*"}]}, 301 {outputIndex:0, inputIndex:22, filters:[{index:18, value:".*"}]}, 302 {outputIndex:0, inputIndex:23, filters:[{index:18, value:".*"}]}, 303 ]; 304 305 // Filter verbs 306 let actual = GetVerbFilters([{tense:"Imperfect Tense", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 307 308 // Assert filtered verbs are correct 309 expect(actual).to.have.deep.members(expected); 310 }); 311 312 it("Should correctly filter verbs for Conditional Tense", function() { 313 // Initialize expected 314 let expected = [ 315 {outputIndex:0, inputIndex:25, filters:[{index:24, value:".*"}]}, 316 {outputIndex:0, inputIndex:26, filters:[{index:24, value:".*"}]}, 317 {outputIndex:0, inputIndex:27, filters:[{index:24, value:".*"}]}, 318 {outputIndex:0, inputIndex:28, filters:[{index:24, value:".*"}]}, 319 {outputIndex:0, inputIndex:29, filters:[{index:24, value:".*"}]}, 320 ]; 321 322 // Filter verbs 323 let actual = GetVerbFilters([{tense:"Conditional Tense", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 324 325 // Assert filtered verbs are correct 326 expect(actual).to.have.deep.members(expected); 327 }); 328 329 it("Should correctly filter verbs for Simple Future Tense", function() { 330 // Initialize expected 331 let expected = [ 332 {outputIndex:0, inputIndex:31, filters:[{index:30, value:".*"}]}, 333 {outputIndex:0, inputIndex:32, filters:[{index:30, value:".*"}]}, 334 {outputIndex:0, inputIndex:33, filters:[{index:30, value:".*"}]}, 335 {outputIndex:0, inputIndex:34, filters:[{index:30, value:".*"}]}, 336 {outputIndex:0, inputIndex:35, filters:[{index:30, value:".*"}]}, 337 ]; 338 339 // Filter verbs 340 let actual = GetVerbFilters([{tense:"Simple Future Tense", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 341 342 // Assert filtered verbs are correct 343 expect(actual).to.have.deep.members(expected); 344 }); 345 346 it("Should correctly filter verbs for Present Subjunctive Tense", function() { 347 // Initialize expected 348 let expected = [ 349 {outputIndex:0, inputIndex:37, filters:[{index:36, value:".*"}]}, 350 {outputIndex:0, inputIndex:38, filters:[{index:36, value:".*"}]}, 351 {outputIndex:0, inputIndex:39, filters:[{index:36, value:".*"}]}, 352 {outputIndex:0, inputIndex:40, filters:[{index:36, value:".*"}]}, 353 {outputIndex:0, inputIndex:41, filters:[{index:36, value:".*"}]}, 354 ]; 355 356 // Filter verbs 357 let actual = GetVerbFilters([{tense:"Present Subjunctive Tense", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 358 359 // Assert filtered verbs are correct 360 expect(actual).to.have.deep.members(expected); 361 }); 362 363 it("Should correctly filter verbs for Imperfect Subjunctive Tense", function() { 364 // Initialize expected 365 let expected = [ 366 {outputIndex:0, inputIndex:43, filters:[{index:42, value:".*"}]}, 367 {outputIndex:0, inputIndex:44, filters:[{index:42, value:".*"}]}, 368 {outputIndex:0, inputIndex:45, filters:[{index:42, value:".*"}]}, 369 {outputIndex:0, inputIndex:46, filters:[{index:42, value:".*"}]}, 370 {outputIndex:0, inputIndex:47, filters:[{index:42, value:".*"}]}, 371 ]; 372 373 // Filter verbs 374 let actual = GetVerbFilters([{tense:"Imperfect Subjunctive Tense", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 375 376 // Assert filtered verbs are correct 377 expect(actual).to.have.deep.members(expected); 378 }); 379 }); 380 381 describe("Regularity filters", function() { 382 it("Should correctly filter regular verbs", function() { 383 // Initialize expected 384 let expected = [ 385 {outputIndex:0, inputIndex:03, filters:[{index:02, value:"Regular"}]}, 386 {outputIndex:0, inputIndex:05, filters:[{index:04, value:"Regular"}]}, 387 {outputIndex:0, inputIndex:07, filters:[{index:06, value:"Regular"}]}, 388 {outputIndex:0, inputIndex:08, filters:[{index:06, value:"Regular"}]}, 389 {outputIndex:0, inputIndex:09, filters:[{index:06, value:"Regular"}]}, 390 {outputIndex:0, inputIndex:10, filters:[{index:06, value:"Regular"}]}, 391 {outputIndex:0, inputIndex:11, filters:[{index:06, value:"Regular"}]}, 392 {outputIndex:0, inputIndex:13, filters:[{index:12, value:"Regular"}]}, 393 {outputIndex:0, inputIndex:14, filters:[{index:12, value:"Regular"}]}, 394 {outputIndex:0, inputIndex:15, filters:[{index:12, value:"Regular"}]}, 395 {outputIndex:0, inputIndex:16, filters:[{index:12, value:"Regular"}]}, 396 {outputIndex:0, inputIndex:17, filters:[{index:12, value:"Regular"}]}, 397 {outputIndex:0, inputIndex:19, filters:[{index:18, value:"Regular"}]}, 398 {outputIndex:0, inputIndex:20, filters:[{index:18, value:"Regular"}]}, 399 {outputIndex:0, inputIndex:21, filters:[{index:18, value:"Regular"}]}, 400 {outputIndex:0, inputIndex:22, filters:[{index:18, value:"Regular"}]}, 401 {outputIndex:0, inputIndex:23, filters:[{index:18, value:"Regular"}]}, 402 {outputIndex:0, inputIndex:25, filters:[{index:24, value:"Regular"}]}, 403 {outputIndex:0, inputIndex:26, filters:[{index:24, value:"Regular"}]}, 404 {outputIndex:0, inputIndex:27, filters:[{index:24, value:"Regular"}]}, 405 {outputIndex:0, inputIndex:28, filters:[{index:24, value:"Regular"}]}, 406 {outputIndex:0, inputIndex:29, filters:[{index:24, value:"Regular"}]}, 407 {outputIndex:0, inputIndex:31, filters:[{index:30, value:"Regular"}]}, 408 {outputIndex:0, inputIndex:32, filters:[{index:30, value:"Regular"}]}, 409 {outputIndex:0, inputIndex:33, filters:[{index:30, value:"Regular"}]}, 410 {outputIndex:0, inputIndex:34, filters:[{index:30, value:"Regular"}]}, 411 {outputIndex:0, inputIndex:35, filters:[{index:30, value:"Regular"}]}, 412 {outputIndex:0, inputIndex:37, filters:[{index:36, value:"Regular"}]}, 413 {outputIndex:0, inputIndex:38, filters:[{index:36, value:"Regular"}]}, 414 {outputIndex:0, inputIndex:39, filters:[{index:36, value:"Regular"}]}, 415 {outputIndex:0, inputIndex:40, filters:[{index:36, value:"Regular"}]}, 416 {outputIndex:0, inputIndex:41, filters:[{index:36, value:"Regular"}]}, 417 {outputIndex:0, inputIndex:43, filters:[{index:42, value:"Regular"}]}, 418 {outputIndex:0, inputIndex:44, filters:[{index:42, value:"Regular"}]}, 419 {outputIndex:0, inputIndex:45, filters:[{index:42, value:"Regular"}]}, 420 {outputIndex:0, inputIndex:46, filters:[{index:42, value:"Regular"}]}, 421 {outputIndex:0, inputIndex:47, filters:[{index:42, value:"Regular"}]}, 422 ]; 423 424 // Filter verbs 425 let actual = GetVerbFilters([{tense:"all tenses", subject:"all subjects", type:"Regular", direction:"Eng. => Conj."}]); 426 427 // Assert filtered verbs are correct 428 expect(actual).to.have.deep.members(expected); 429 }); 430 431 it("Should correctly filter reflexive verbs", function() { 432 // Initialize expected 433 let expected = [ 434 {outputIndex:0, inputIndex:03, filters:[{index:02, value:"Reflexive"}]}, 435 {outputIndex:0, inputIndex:05, filters:[{index:04, value:"Reflexive"}]}, 436 {outputIndex:0, inputIndex:07, filters:[{index:06, value:"Reflexive"}]}, 437 {outputIndex:0, inputIndex:08, filters:[{index:06, value:"Reflexive"}]}, 438 {outputIndex:0, inputIndex:09, filters:[{index:06, value:"Reflexive"}]}, 439 {outputIndex:0, inputIndex:10, filters:[{index:06, value:"Reflexive"}]}, 440 {outputIndex:0, inputIndex:11, filters:[{index:06, value:"Reflexive"}]}, 441 {outputIndex:0, inputIndex:13, filters:[{index:12, value:"Reflexive"}]}, 442 {outputIndex:0, inputIndex:14, filters:[{index:12, value:"Reflexive"}]}, 443 {outputIndex:0, inputIndex:15, filters:[{index:12, value:"Reflexive"}]}, 444 {outputIndex:0, inputIndex:16, filters:[{index:12, value:"Reflexive"}]}, 445 {outputIndex:0, inputIndex:17, filters:[{index:12, value:"Reflexive"}]}, 446 {outputIndex:0, inputIndex:19, filters:[{index:18, value:"Reflexive"}]}, 447 {outputIndex:0, inputIndex:20, filters:[{index:18, value:"Reflexive"}]}, 448 {outputIndex:0, inputIndex:21, filters:[{index:18, value:"Reflexive"}]}, 449 {outputIndex:0, inputIndex:22, filters:[{index:18, value:"Reflexive"}]}, 450 {outputIndex:0, inputIndex:23, filters:[{index:18, value:"Reflexive"}]}, 451 {outputIndex:0, inputIndex:25, filters:[{index:24, value:"Reflexive"}]}, 452 {outputIndex:0, inputIndex:26, filters:[{index:24, value:"Reflexive"}]}, 453 {outputIndex:0, inputIndex:27, filters:[{index:24, value:"Reflexive"}]}, 454 {outputIndex:0, inputIndex:28, filters:[{index:24, value:"Reflexive"}]}, 455 {outputIndex:0, inputIndex:29, filters:[{index:24, value:"Reflexive"}]}, 456 {outputIndex:0, inputIndex:31, filters:[{index:30, value:"Reflexive"}]}, 457 {outputIndex:0, inputIndex:32, filters:[{index:30, value:"Reflexive"}]}, 458 {outputIndex:0, inputIndex:33, filters:[{index:30, value:"Reflexive"}]}, 459 {outputIndex:0, inputIndex:34, filters:[{index:30, value:"Reflexive"}]}, 460 {outputIndex:0, inputIndex:35, filters:[{index:30, value:"Reflexive"}]}, 461 {outputIndex:0, inputIndex:37, filters:[{index:36, value:"Reflexive"}]}, 462 {outputIndex:0, inputIndex:38, filters:[{index:36, value:"Reflexive"}]}, 463 {outputIndex:0, inputIndex:39, filters:[{index:36, value:"Reflexive"}]}, 464 {outputIndex:0, inputIndex:40, filters:[{index:36, value:"Reflexive"}]}, 465 {outputIndex:0, inputIndex:41, filters:[{index:36, value:"Reflexive"}]}, 466 {outputIndex:0, inputIndex:43, filters:[{index:42, value:"Reflexive"}]}, 467 {outputIndex:0, inputIndex:44, filters:[{index:42, value:"Reflexive"}]}, 468 {outputIndex:0, inputIndex:45, filters:[{index:42, value:"Reflexive"}]}, 469 {outputIndex:0, inputIndex:46, filters:[{index:42, value:"Reflexive"}]}, 470 {outputIndex:0, inputIndex:47, filters:[{index:42, value:"Reflexive"}]}, 471 ]; 472 473 // Filter verbs 474 let actual = GetVerbFilters([{tense:"all tenses", subject:"all subjects", type:"Reflexive", direction:"Eng. => Conj."}]); 475 476 // Assert filtered verbs are correct 477 expect(actual).to.have.deep.members(expected); 478 }); 479 480 it("Should correctly filter stem changing verbs", function() { 481 // Initialize expected 482 let expected = [ 483 {outputIndex:0, inputIndex:03, filters:[{index:02, value:"Stem Changing"}]}, 484 {outputIndex:0, inputIndex:05, filters:[{index:04, value:"Stem Changing"}]}, 485 {outputIndex:0, inputIndex:07, filters:[{index:06, value:"Stem Changing"}]}, 486 {outputIndex:0, inputIndex:08, filters:[{index:06, value:"Stem Changing"}]}, 487 {outputIndex:0, inputIndex:09, filters:[{index:06, value:"Stem Changing"}]}, 488 {outputIndex:0, inputIndex:10, filters:[{index:06, value:"Stem Changing"}]}, 489 {outputIndex:0, inputIndex:11, filters:[{index:06, value:"Stem Changing"}]}, 490 {outputIndex:0, inputIndex:13, filters:[{index:12, value:"Stem Changing"}]}, 491 {outputIndex:0, inputIndex:14, filters:[{index:12, value:"Stem Changing"}]}, 492 {outputIndex:0, inputIndex:15, filters:[{index:12, value:"Stem Changing"}]}, 493 {outputIndex:0, inputIndex:16, filters:[{index:12, value:"Stem Changing"}]}, 494 {outputIndex:0, inputIndex:17, filters:[{index:12, value:"Stem Changing"}]}, 495 {outputIndex:0, inputIndex:19, filters:[{index:18, value:"Stem Changing"}]}, 496 {outputIndex:0, inputIndex:20, filters:[{index:18, value:"Stem Changing"}]}, 497 {outputIndex:0, inputIndex:21, filters:[{index:18, value:"Stem Changing"}]}, 498 {outputIndex:0, inputIndex:22, filters:[{index:18, value:"Stem Changing"}]}, 499 {outputIndex:0, inputIndex:23, filters:[{index:18, value:"Stem Changing"}]}, 500 {outputIndex:0, inputIndex:25, filters:[{index:24, value:"Stem Changing"}]}, 501 {outputIndex:0, inputIndex:26, filters:[{index:24, value:"Stem Changing"}]}, 502 {outputIndex:0, inputIndex:27, filters:[{index:24, value:"Stem Changing"}]}, 503 {outputIndex:0, inputIndex:28, filters:[{index:24, value:"Stem Changing"}]}, 504 {outputIndex:0, inputIndex:29, filters:[{index:24, value:"Stem Changing"}]}, 505 {outputIndex:0, inputIndex:31, filters:[{index:30, value:"Stem Changing"}]}, 506 {outputIndex:0, inputIndex:32, filters:[{index:30, value:"Stem Changing"}]}, 507 {outputIndex:0, inputIndex:33, filters:[{index:30, value:"Stem Changing"}]}, 508 {outputIndex:0, inputIndex:34, filters:[{index:30, value:"Stem Changing"}]}, 509 {outputIndex:0, inputIndex:35, filters:[{index:30, value:"Stem Changing"}]}, 510 {outputIndex:0, inputIndex:37, filters:[{index:36, value:"Stem Changing"}]}, 511 {outputIndex:0, inputIndex:38, filters:[{index:36, value:"Stem Changing"}]}, 512 {outputIndex:0, inputIndex:39, filters:[{index:36, value:"Stem Changing"}]}, 513 {outputIndex:0, inputIndex:40, filters:[{index:36, value:"Stem Changing"}]}, 514 {outputIndex:0, inputIndex:41, filters:[{index:36, value:"Stem Changing"}]}, 515 {outputIndex:0, inputIndex:43, filters:[{index:42, value:"Stem Changing"}]}, 516 {outputIndex:0, inputIndex:44, filters:[{index:42, value:"Stem Changing"}]}, 517 {outputIndex:0, inputIndex:45, filters:[{index:42, value:"Stem Changing"}]}, 518 {outputIndex:0, inputIndex:46, filters:[{index:42, value:"Stem Changing"}]}, 519 {outputIndex:0, inputIndex:47, filters:[{index:42, value:"Stem Changing"}]}, 520 ]; 521 522 // Filter verbs 523 let actual = GetVerbFilters([{tense:"all tenses", subject:"all subjects", type:"Stem Changing", direction:"Eng. => Conj."}]); 524 525 // Assert filtered verbs are correct 526 expect(actual).to.have.deep.members(expected); 527 }); 528 529 it("Should correctly filter orthographic verbs", function() { 530 // Initialize expected 531 let expected = [ 532 {outputIndex:0, inputIndex:03, filters:[{index:02, value:"Orthographic"}]}, 533 {outputIndex:0, inputIndex:05, filters:[{index:04, value:"Orthographic"}]}, 534 {outputIndex:0, inputIndex:07, filters:[{index:06, value:"Orthographic"}]}, 535 {outputIndex:0, inputIndex:08, filters:[{index:06, value:"Orthographic"}]}, 536 {outputIndex:0, inputIndex:09, filters:[{index:06, value:"Orthographic"}]}, 537 {outputIndex:0, inputIndex:10, filters:[{index:06, value:"Orthographic"}]}, 538 {outputIndex:0, inputIndex:11, filters:[{index:06, value:"Orthographic"}]}, 539 {outputIndex:0, inputIndex:13, filters:[{index:12, value:"Orthographic"}]}, 540 {outputIndex:0, inputIndex:14, filters:[{index:12, value:"Orthographic"}]}, 541 {outputIndex:0, inputIndex:15, filters:[{index:12, value:"Orthographic"}]}, 542 {outputIndex:0, inputIndex:16, filters:[{index:12, value:"Orthographic"}]}, 543 {outputIndex:0, inputIndex:17, filters:[{index:12, value:"Orthographic"}]}, 544 {outputIndex:0, inputIndex:19, filters:[{index:18, value:"Orthographic"}]}, 545 {outputIndex:0, inputIndex:20, filters:[{index:18, value:"Orthographic"}]}, 546 {outputIndex:0, inputIndex:21, filters:[{index:18, value:"Orthographic"}]}, 547 {outputIndex:0, inputIndex:22, filters:[{index:18, value:"Orthographic"}]}, 548 {outputIndex:0, inputIndex:23, filters:[{index:18, value:"Orthographic"}]}, 549 {outputIndex:0, inputIndex:25, filters:[{index:24, value:"Orthographic"}]}, 550 {outputIndex:0, inputIndex:26, filters:[{index:24, value:"Orthographic"}]}, 551 {outputIndex:0, inputIndex:27, filters:[{index:24, value:"Orthographic"}]}, 552 {outputIndex:0, inputIndex:28, filters:[{index:24, value:"Orthographic"}]}, 553 {outputIndex:0, inputIndex:29, filters:[{index:24, value:"Orthographic"}]}, 554 {outputIndex:0, inputIndex:31, filters:[{index:30, value:"Orthographic"}]}, 555 {outputIndex:0, inputIndex:32, filters:[{index:30, value:"Orthographic"}]}, 556 {outputIndex:0, inputIndex:33, filters:[{index:30, value:"Orthographic"}]}, 557 {outputIndex:0, inputIndex:34, filters:[{index:30, value:"Orthographic"}]}, 558 {outputIndex:0, inputIndex:35, filters:[{index:30, value:"Orthographic"}]}, 559 {outputIndex:0, inputIndex:37, filters:[{index:36, value:"Orthographic"}]}, 560 {outputIndex:0, inputIndex:38, filters:[{index:36, value:"Orthographic"}]}, 561 {outputIndex:0, inputIndex:39, filters:[{index:36, value:"Orthographic"}]}, 562 {outputIndex:0, inputIndex:40, filters:[{index:36, value:"Orthographic"}]}, 563 {outputIndex:0, inputIndex:41, filters:[{index:36, value:"Orthographic"}]}, 564 {outputIndex:0, inputIndex:43, filters:[{index:42, value:"Orthographic"}]}, 565 {outputIndex:0, inputIndex:44, filters:[{index:42, value:"Orthographic"}]}, 566 {outputIndex:0, inputIndex:45, filters:[{index:42, value:"Orthographic"}]}, 567 {outputIndex:0, inputIndex:46, filters:[{index:42, value:"Orthographic"}]}, 568 {outputIndex:0, inputIndex:47, filters:[{index:42, value:"Orthographic"}]}, 569 ]; 570 571 // Filter verbs 572 let actual = GetVerbFilters([{tense:"all tenses", subject:"all subjects", type:"Orthographic", direction:"Eng. => Conj."}]); 573 574 // Assert filtered verbs are correct 575 expect(actual).to.have.deep.members(expected); 576 }); 577 578 it("Should correctly filter irregular verbs", function() { 579 // Initialize expected 580 let expected = [ 581 {outputIndex:0, inputIndex:03, filters:[{index:02, value:"Irregular"}]}, 582 {outputIndex:0, inputIndex:05, filters:[{index:04, value:"Irregular"}]}, 583 {outputIndex:0, inputIndex:07, filters:[{index:06, value:"Irregular"}]}, 584 {outputIndex:0, inputIndex:08, filters:[{index:06, value:"Irregular"}]}, 585 {outputIndex:0, inputIndex:09, filters:[{index:06, value:"Irregular"}]}, 586 {outputIndex:0, inputIndex:10, filters:[{index:06, value:"Irregular"}]}, 587 {outputIndex:0, inputIndex:11, filters:[{index:06, value:"Irregular"}]}, 588 {outputIndex:0, inputIndex:13, filters:[{index:12, value:"Irregular"}]}, 589 {outputIndex:0, inputIndex:14, filters:[{index:12, value:"Irregular"}]}, 590 {outputIndex:0, inputIndex:15, filters:[{index:12, value:"Irregular"}]}, 591 {outputIndex:0, inputIndex:16, filters:[{index:12, value:"Irregular"}]}, 592 {outputIndex:0, inputIndex:17, filters:[{index:12, value:"Irregular"}]}, 593 {outputIndex:0, inputIndex:19, filters:[{index:18, value:"Irregular"}]}, 594 {outputIndex:0, inputIndex:20, filters:[{index:18, value:"Irregular"}]}, 595 {outputIndex:0, inputIndex:21, filters:[{index:18, value:"Irregular"}]}, 596 {outputIndex:0, inputIndex:22, filters:[{index:18, value:"Irregular"}]}, 597 {outputIndex:0, inputIndex:23, filters:[{index:18, value:"Irregular"}]}, 598 {outputIndex:0, inputIndex:25, filters:[{index:24, value:"Irregular"}]}, 599 {outputIndex:0, inputIndex:26, filters:[{index:24, value:"Irregular"}]}, 600 {outputIndex:0, inputIndex:27, filters:[{index:24, value:"Irregular"}]}, 601 {outputIndex:0, inputIndex:28, filters:[{index:24, value:"Irregular"}]}, 602 {outputIndex:0, inputIndex:29, filters:[{index:24, value:"Irregular"}]}, 603 {outputIndex:0, inputIndex:31, filters:[{index:30, value:"Irregular"}]}, 604 {outputIndex:0, inputIndex:32, filters:[{index:30, value:"Irregular"}]}, 605 {outputIndex:0, inputIndex:33, filters:[{index:30, value:"Irregular"}]}, 606 {outputIndex:0, inputIndex:34, filters:[{index:30, value:"Irregular"}]}, 607 {outputIndex:0, inputIndex:35, filters:[{index:30, value:"Irregular"}]}, 608 {outputIndex:0, inputIndex:37, filters:[{index:36, value:"Irregular"}]}, 609 {outputIndex:0, inputIndex:38, filters:[{index:36, value:"Irregular"}]}, 610 {outputIndex:0, inputIndex:39, filters:[{index:36, value:"Irregular"}]}, 611 {outputIndex:0, inputIndex:40, filters:[{index:36, value:"Irregular"}]}, 612 {outputIndex:0, inputIndex:41, filters:[{index:36, value:"Irregular"}]}, 613 {outputIndex:0, inputIndex:43, filters:[{index:42, value:"Irregular"}]}, 614 {outputIndex:0, inputIndex:44, filters:[{index:42, value:"Irregular"}]}, 615 {outputIndex:0, inputIndex:45, filters:[{index:42, value:"Irregular"}]}, 616 {outputIndex:0, inputIndex:46, filters:[{index:42, value:"Irregular"}]}, 617 {outputIndex:0, inputIndex:47, filters:[{index:42, value:"Irregular"}]}, 618 ]; 619 620 // Filter verbs 621 let actual = GetVerbFilters([{tense:"all tenses", subject:"all subjects", type:"irregular", direction:"Eng. => Conj."}]); 622 623 // Assert filtered verbs are correct 624 expect(actual).to.have.deep.members(expected); 625 }); 626 627 it("Should correctly filter nonregular verbs", function() { 628 // Initialize expected 629 let expected = [ 630 {outputIndex:0, inputIndex:03, filters:[{index:02, value:"Irregular|Stem Changing|Orthographic"}]}, 631 {outputIndex:0, inputIndex:05, filters:[{index:04, value:"Irregular|Stem Changing|Orthographic"}]}, 632 {outputIndex:0, inputIndex:07, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 633 {outputIndex:0, inputIndex:08, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 634 {outputIndex:0, inputIndex:09, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 635 {outputIndex:0, inputIndex:10, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 636 {outputIndex:0, inputIndex:11, filters:[{index:06, value:"Irregular|Stem Changing|Orthographic"}]}, 637 {outputIndex:0, inputIndex:13, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 638 {outputIndex:0, inputIndex:14, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 639 {outputIndex:0, inputIndex:15, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 640 {outputIndex:0, inputIndex:16, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 641 {outputIndex:0, inputIndex:17, filters:[{index:12, value:"Irregular|Stem Changing|Orthographic"}]}, 642 {outputIndex:0, inputIndex:19, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 643 {outputIndex:0, inputIndex:20, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 644 {outputIndex:0, inputIndex:21, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 645 {outputIndex:0, inputIndex:22, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 646 {outputIndex:0, inputIndex:23, filters:[{index:18, value:"Irregular|Stem Changing|Orthographic"}]}, 647 {outputIndex:0, inputIndex:25, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 648 {outputIndex:0, inputIndex:26, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 649 {outputIndex:0, inputIndex:27, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 650 {outputIndex:0, inputIndex:28, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 651 {outputIndex:0, inputIndex:29, filters:[{index:24, value:"Irregular|Stem Changing|Orthographic"}]}, 652 {outputIndex:0, inputIndex:31, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 653 {outputIndex:0, inputIndex:32, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 654 {outputIndex:0, inputIndex:33, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 655 {outputIndex:0, inputIndex:34, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 656 {outputIndex:0, inputIndex:35, filters:[{index:30, value:"Irregular|Stem Changing|Orthographic"}]}, 657 {outputIndex:0, inputIndex:37, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 658 {outputIndex:0, inputIndex:38, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 659 {outputIndex:0, inputIndex:39, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 660 {outputIndex:0, inputIndex:40, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 661 {outputIndex:0, inputIndex:41, filters:[{index:36, value:"Irregular|Stem Changing|Orthographic"}]}, 662 {outputIndex:0, inputIndex:43, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 663 {outputIndex:0, inputIndex:44, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 664 {outputIndex:0, inputIndex:45, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 665 {outputIndex:0, inputIndex:46, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 666 {outputIndex:0, inputIndex:47, filters:[{index:42, value:"Irregular|Stem Changing|Orthographic"}]}, 667 ]; 668 669 // Filter verbs 670 let actual = GetVerbFilters([{tense:"all tenses", subject:"all subjects", type:"Nonregular", direction:"Eng. => Conj."}]); 671 672 // Assert filtered verbs are correct 673 expect(actual).to.have.deep.members(expected); 674 }); 675 }); 676 677 describe("Subject filters", function() { 678 it("Should correctly filter type subjects", function() { 679 // Initialize expected 680 let expected = [ 681 {outputIndex:0, inputIndex:02, filters:[{index:02, value:".*"}]}, 682 {outputIndex:0, inputIndex:04, filters:[{index:04, value:".*"}]}, 683 {outputIndex:0, inputIndex:06, filters:[{index:06, value:".*"}]}, 684 {outputIndex:0, inputIndex:12, filters:[{index:12, value:".*"}]}, 685 {outputIndex:0, inputIndex:18, filters:[{index:18, value:".*"}]}, 686 {outputIndex:0, inputIndex:24, filters:[{index:24, value:".*"}]}, 687 {outputIndex:0, inputIndex:30, filters:[{index:30, value:".*"}]}, 688 {outputIndex:0, inputIndex:36, filters:[{index:36, value:".*"}]}, 689 {outputIndex:0, inputIndex:42, filters:[{index:42, value:".*"}]}, 690 ]; 691 692 // Filter verbs 693 let actual = GetVerbFilters([{tense:"all tenses", subject:"type", type:"all types", direction:"Eng. => Conj."}]); 694 695 // Assert filtered verbs are correct 696 expect(actual).to.have.deep.members(expected); 697 }); 698 699 it("Should correctly filter yo subjects", function() { 700 // Initialize expected 701 let expected = [ 702 {outputIndex:0, inputIndex:03, filters:[{index:02, value:".*"}]}, 703 {outputIndex:0, inputIndex:05, filters:[{index:04, value:".*"}]}, 704 {outputIndex:0, inputIndex:07, filters:[{index:06, value:".*"}]}, 705 {outputIndex:0, inputIndex:13, filters:[{index:12, value:".*"}]}, 706 {outputIndex:0, inputIndex:19, filters:[{index:18, value:".*"}]}, 707 {outputIndex:0, inputIndex:25, filters:[{index:24, value:".*"}]}, 708 {outputIndex:0, inputIndex:31, filters:[{index:30, value:".*"}]}, 709 {outputIndex:0, inputIndex:37, filters:[{index:36, value:".*"}]}, 710 {outputIndex:0, inputIndex:43, filters:[{index:42, value:".*"}]}, 711 ]; 712 713 // Filter verbs 714 let actual = GetVerbFilters([{tense:"all tenses", subject:"yo", type:"all types", direction:"Eng. => Conj."}]); 715 716 // Assert filtered verbs are correct 717 expect(actual).to.have.deep.members(expected); 718 }); 719 720 it("Should correctly filter tú subjects", function() { 721 // Initialize expected 722 let expected = [ 723 {outputIndex:0, inputIndex:03, filters:[{index:02, value:".*"}]}, 724 {outputIndex:0, inputIndex:05, filters:[{index:04, value:".*"}]}, 725 {outputIndex:0, inputIndex:08, filters:[{index:06, value:".*"}]}, 726 {outputIndex:0, inputIndex:14, filters:[{index:12, value:".*"}]}, 727 {outputIndex:0, inputIndex:20, filters:[{index:18, value:".*"}]}, 728 {outputIndex:0, inputIndex:26, filters:[{index:24, value:".*"}]}, 729 {outputIndex:0, inputIndex:32, filters:[{index:30, value:".*"}]}, 730 {outputIndex:0, inputIndex:38, filters:[{index:36, value:".*"}]}, 731 {outputIndex:0, inputIndex:44, filters:[{index:42, value:".*"}]}, 732 ]; 733 734 // Filter verbs 735 let actual = GetVerbFilters([{tense:"all tenses", subject:"tú", type:"all types", direction:"Eng. => Conj."}]); 736 737 // Assert filtered verbs are correct 738 expect(actual).to.have.deep.members(expected); 739 }); 740 741 it("Should correctly filter él subjects", function() { 742 // Initialize expected 743 let expected = [ 744 {outputIndex:0, inputIndex:03, filters:[{index:02, value:".*"}]}, 745 {outputIndex:0, inputIndex:05, filters:[{index:04, value:".*"}]}, 746 {outputIndex:0, inputIndex:09, filters:[{index:06, value:".*"}]}, 747 {outputIndex:0, inputIndex:15, filters:[{index:12, value:".*"}]}, 748 {outputIndex:0, inputIndex:21, filters:[{index:18, value:".*"}]}, 749 {outputIndex:0, inputIndex:27, filters:[{index:24, value:".*"}]}, 750 {outputIndex:0, inputIndex:33, filters:[{index:30, value:".*"}]}, 751 {outputIndex:0, inputIndex:39, filters:[{index:36, value:".*"}]}, 752 {outputIndex:0, inputIndex:45, filters:[{index:42, value:".*"}]}, 753 ]; 754 755 // Filter verbs 756 let actual = GetVerbFilters([{tense:"all tenses", subject:"él", type:"all types", direction:"Eng. => Conj."}]); 757 758 // Assert filtered verbs are correct 759 expect(actual).to.have.deep.members(expected); 760 }); 761 762 it("Should correctly filter nosotros subjects", function() { 763 // Initialize expected 764 let expected = [ 765 {outputIndex:0, inputIndex:03, filters:[{index:02, value:".*"}]}, 766 {outputIndex:0, inputIndex:05, filters:[{index:04, value:".*"}]}, 767 {outputIndex:0, inputIndex:10, filters:[{index:06, value:".*"}]}, 768 {outputIndex:0, inputIndex:16, filters:[{index:12, value:".*"}]}, 769 {outputIndex:0, inputIndex:22, filters:[{index:18, value:".*"}]}, 770 {outputIndex:0, inputIndex:28, filters:[{index:24, value:".*"}]}, 771 {outputIndex:0, inputIndex:34, filters:[{index:30, value:".*"}]}, 772 {outputIndex:0, inputIndex:40, filters:[{index:36, value:".*"}]}, 773 {outputIndex:0, inputIndex:46, filters:[{index:42, value:".*"}]}, 774 ]; 775 776 // Filter verbs 777 let actual = GetVerbFilters([{tense:"all tenses", subject:"nosotros", type:"all types", direction:"Eng. => Conj."}]); 778 779 // Assert filtered verbs are correct 780 expect(actual).to.have.deep.members(expected); 781 }); 782 783 it("Should correctly filter ellos subjects", function() { 784 // Initialize expected 785 let expected = [ 786 {outputIndex:0, inputIndex:03, filters:[{index:02, value:".*"}]}, 787 {outputIndex:0, inputIndex:05, filters:[{index:04, value:".*"}]}, 788 {outputIndex:0, inputIndex:11, filters:[{index:06, value:".*"}]}, 789 {outputIndex:0, inputIndex:17, filters:[{index:12, value:".*"}]}, 790 {outputIndex:0, inputIndex:23, filters:[{index:18, value:".*"}]}, 791 {outputIndex:0, inputIndex:29, filters:[{index:24, value:".*"}]}, 792 {outputIndex:0, inputIndex:35, filters:[{index:30, value:".*"}]}, 793 {outputIndex:0, inputIndex:41, filters:[{index:36, value:".*"}]}, 794 {outputIndex:0, inputIndex:47, filters:[{index:42, value:".*"}]}, 795 ]; 796 797 // Filter verbs 798 let actual = GetVerbFilters([{tense:"all tenses", subject:"ellos", type:"all types", direction:"Eng. => Conj."}]); 799 800 // Assert filtered verbs are correct 801 expect(actual).to.have.deep.members(expected); 802 }); 803 }); 804 805 describe("Direction filters", function() { 806 it("Should correctly filter English to Conjugations", function() { 807 // Initialize expected 808 let expected = [ 809 {outputIndex:0, inputIndex:3, filters:[{index:2, value:".*"}]}, 810 ]; 811 812 // Filter verbs 813 let actual = GetVerbFilters([{tense:"present participles", subject:"all subjects", type:"all types", direction:"Eng. => Conj."}]); 814 815 // Assert filtered verbs are correct 816 expect(actual).to.have.deep.members(expected); 817 }); 818 819 it("Should correctly filter Spanish to Conjugations", function() { 820 // Initialize expected 821 let expected = [ 822 {outputIndex:1, inputIndex:3, filters:[{index:2, value:".*"}]}, 823 ]; 824 825 // Filter verbs 826 let actual = GetVerbFilters([{tense:"present participles", subject:"all subjects", type:"all types", direction:"Esp. => Conj."}]); 827 828 // Assert filtered verbs are correct 829 expect(actual).to.have.deep.members(expected); 830 }); 831 832 it("Should correctly filter Conjugations to English", function() { 833 // Initialize expected 834 let expected = [ 835 {outputIndex:3, inputIndex:0, filters:[{index:2, value:".*"}]}, 836 ]; 837 838 // Filter verbs 839 let actual = GetVerbFilters([{tense:"present participles", subject:"all subjects", type:"all types", direction:"Conj. => Eng."}]); 840 841 // Assert filtered verbs are correct 842 expect(actual).to.have.deep.members(expected); 843 }); 844 845 it("Should correctly filter Conjugations to Spanish", function() { 846 // Initialize expected 847 let expected = [ 848 {outputIndex:3, inputIndex:1, filters:[{index:2, value:".*"}]}, 849 ]; 850 851 // Filter verbs 852 let actual = GetVerbFilters([{tense:"present participles", subject:"all subjects", type:"all types", direction:"Conj. => Esp."}]); 853 854 // Assert filtered verbs are correct 855 expect(actual).to.have.deep.members(expected); 856 }); 857 }); 858 }); 859 860 describe("ApplyFilters method", function() { 861 // Initialize vocab 862 let vocab = [ 863 ["Upper", "Lower", "Type1", "Type2"], 864 ["A", "a", "Noun", "Vowel"], 865 ["B", "b", "Adjective", "Consonant"], 866 ["C", "c", "Verb", "Consonant"], 867 ]; 868 869 it("Should correctly filter different outputIndexes", function() { 870 // Initialize expected 871 let expected = [ 872 ["Upper", "A", "Lower", "a"], 873 ["Upper", "B", "Lower", "b"], 874 ["Upper", "C", "Lower", "c"], 875 ["Type2", "Vowel", "Lower", "a"], 876 ["Type2", "Consonant", "Lower", "b"], 877 ["Type2", "Consonant", "Lower", "c"], 878 ]; 879 880 // Call ApplyFilters 881 let actual = ApplyFilters(vocab, [ 882 {outputIndex:0, inputIndex:1, filters:[{index:2, value:".*"}]}, 883 {outputIndex:3, inputIndex:1, filters:[{index:2, value:".*"}]}, 884 ]); 885 886 // Assert filtered vocab is correct 887 expect(actual).to.have.deep.members(expected); 888 }); 889 890 it("Should correctly filter different inputIndexes", function() { 891 // Initialize expected 892 let expected = [ 893 ["Upper", "A", "Lower", "a"], 894 ["Upper", "B", "Lower", "b"], 895 ["Upper", "C", "Lower", "c"], 896 ["Upper", "A", "Type2", "Vowel"], 897 ["Upper", "B", "Type2", "Consonant"], 898 ["Upper", "C", "Type2", "Consonant"], 899 ]; 900 901 // Call ApplyFilters 902 let actual = ApplyFilters(vocab, [ 903 {outputIndex:0, inputIndex:1, filters:[{index:2, value:".*"}]}, 904 {outputIndex:0, inputIndex:3, filters:[{index:2, value:".*"}]}, 905 ]); 906 907 // Assert filtered vocab is correct 908 expect(actual).to.have.deep.members(expected); 909 }); 910 911 it("Should correctly filter different filterIndexes and filtervalues", function() { 912 // Initialize expected 913 let expected = [ 914 ["Upper", "C", "Lower", "c"], 915 ["Upper", "A", "Lower", "a"], 916 ]; 917 918 // Call ApplyFilters 919 let actual = ApplyFilters(vocab, [ 920 {outputIndex:0, inputIndex:1, filters:[{index:2, value:"Verb"}]}, 921 {outputIndex:0, inputIndex:1, filters:[{index:3, value:"Vowel"}]}, 922 ]); 923 924 // Assert filtered vocab is correct 925 expect(actual).to.have.deep.members(expected); 926 }); 927 928 it("Should correctly filter multiple filters", function() { 929 // Initialize expected 930 let expected = [ 931 ["Upper", "C", "Lower", "c"], 932 ]; 933 934 // Call ApplyFilters 935 let actual = ApplyFilters(vocab, [ 936 {outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Verb"}, {index:3, value:"Consonant"}]}, 937 ]); 938 939 // Assert filtered vocab is correct 940 expect(actual).to.have.deep.members(expected); 941 }); 942 943 describe("multiplePrompts setting", function() { 944 // Initialize vocab2 945 let vocab2 = [ 946 ["Upper", "Lower", "Type1"], 947 ["A1, A2 , A3", "a", "Noun"], 948 ["B1, B2", "b", "Adjective"], 949 ["C", "c", "Verb"], 950 ]; 951 952 it("Should't effect prompts by default", function() { 953 // Initialize expected 954 let expected = [ 955 ["Upper", "A1, A2 , A3", "Lower", "a"], 956 ["Upper", "B1, B2", "Lower", "b"], 957 ]; 958 959 // Call ApplyFilters 960 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Adjective"}]}]); 961 962 // Assert filtered vocab is correct 963 expect(actual).to.have.deep.members(expected); 964 }); 965 966 it("Shouldn't effect single prompts", function() { 967 // Initialize expected 968 let expected = [ 969 ["Upper", "C", "Lower", "c"], 970 ]; 971 972 // Call ApplyFilters 973 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[{index:2, value:"Verb"}]}], {multiplePrompts:"Show separately"}); 974 975 // Assert filtered vocab is correct 976 expect(actual).to.have.deep.members(expected); 977 }); 978 979 it("Should't effect prompts if equal to 'Show together'", function() { 980 // Initialize expected 981 let expected = [ 982 ["Upper", "A1, A2 , A3", "Lower", "a"], 983 ["Upper", "B1, B2", "Lower", "b"], 984 ]; 985 986 // Call ApplyFilters 987 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Adjective"}]}], {multiplePrompts:"Show together"}); 988 989 // Assert filtered vocab is correct 990 expect(actual).to.have.deep.members(expected); 991 }); 992 993 it("Should split up prompts if equal to 'Show separately'", function() { 994 // Initialize expected 995 let expected = [ 996 ["Upper", "A1", "Lower", "a"], 997 ["Upper", "A2", "Lower", "a"], 998 ["Upper", "A3", "Lower", "a"], 999 ["Upper", "B1", "Lower", "b"], 1000 ["Upper", "B2", "Lower", "b"], 1001 ]; 1002 1003 // Call ApplyFilters 1004 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Adjective"}]}], {multiplePrompts:"Show separately"}); 1005 1006 // Assert filtered vocab is correct 1007 expect(actual).to.have.deep.members(expected); 1008 }); 1009 1010 it("Should correctly filter prompts if equal to 'Show one' (Math.random returns 0)", function() { 1011 // Initialize expected 1012 let expected = [ 1013 ["Upper", "A1", "Lower", "a"], 1014 ["Upper", "B1", "Lower", "b"], 1015 ]; 1016 1017 // Copy original Math.random method 1018 let random = Math.random; 1019 1020 try { 1021 // Override Math.random method 1022 Math.random = function() { 1023 return 0; 1024 } 1025 1026 // Call ApplyFilters 1027 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Adjective"}]}], {multiplePrompts:"Show one"}); 1028 1029 // Assert filtered vocab is correct 1030 expect(actual).to.have.deep.members(expected); 1031 } 1032 finally { 1033 // Restore Math.random method 1034 Math.random = random; 1035 } 1036 }); 1037 1038 it("Should correctly filter prompts if equal to 'Show one' (Math.random returns 0.5)", function() { 1039 // Initialize expected 1040 let expected = [ 1041 ["Upper", "A2", "Lower", "a"], 1042 ["Upper", "B1", "Lower", "b"], 1043 ]; 1044 1045 // Copy original Math.random method 1046 let random = Math.random; 1047 1048 try { 1049 // Override Math.random method 1050 Math.random = function() { 1051 return 0.5; 1052 } 1053 1054 // Call ApplyFilters 1055 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Adjective"}]}], {multiplePrompts:"Show one"}); 1056 1057 // Assert filtered vocab is correct 1058 expect(actual).to.have.deep.members(expected); 1059 } 1060 finally { 1061 // Restore Math.random method 1062 Math.random = random; 1063 } 1064 }); 1065 1066 it("Should correctly filter prompts if equal to 'Show one' (Math.random returns 1)", function() { 1067 // Initialize expected 1068 let expected = [ 1069 ["Upper", "A3", "Lower", "a"], 1070 ["Upper", "B2", "Lower", "b"], 1071 ]; 1072 1073 // Copy original Math.random method 1074 let random = Math.random; 1075 1076 try { 1077 // Override Math.random method 1078 Math.random = function() { 1079 return 1; 1080 } 1081 1082 // Call ApplyFilters 1083 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Adjective"}]}], {multiplePrompts:"Show one"}); 1084 1085 // Assert filtered vocab is correct 1086 expect(actual).to.have.deep.members(expected); 1087 } 1088 finally { 1089 // Restore Math.random method 1090 Math.random = random; 1091 } 1092 }); 1093 }); 1094 1095 describe("removeDuplicates setting", function() { 1096 // Initialize vocab2 1097 let vocab2 = [ 1098 ["Upper", "Lower", "Type"], 1099 ["A", "a", "Noun"], 1100 ["B", "b", "Adjective"], 1101 ["C", "c", "Verb"], 1102 ]; 1103 1104 it("Should't remove duplicate prompts by default", function() { 1105 // Initialize expected 1106 let expected = [ 1107 ["Upper", "A", "Lower", "a"], 1108 ["Upper", "B", "Lower", "b"], 1109 ["Upper", "C", "Lower", "c"], 1110 ["Upper", "A", "Lower", "a"], 1111 ["Upper", "B", "Lower", "b"], 1112 ]; 1113 1114 // Call ApplyFilters 1115 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[]}, {outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Adjective"}]}]); 1116 1117 // Assert filtered vocab is correct 1118 expect(actual).to.have.deep.members(expected); 1119 }); 1120 1121 it("Should't remove duplicate prompts if equal to false", function() { 1122 // Initialize expected 1123 let expected = [ 1124 ["Upper", "A", "Lower", "a"], 1125 ["Upper", "B", "Lower", "b"], 1126 ["Upper", "C", "Lower", "c"], 1127 ["Upper", "A", "Lower", "a"], 1128 ["Upper", "B", "Lower", "b"], 1129 ]; 1130 1131 // Call ApplyFilters 1132 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[]}, {outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Adjective"}]}], {removeDuplicates:false}); 1133 1134 // Assert filtered vocab is correct 1135 expect(actual).to.have.deep.members(expected); 1136 }); 1137 1138 it("Should remove duplicate prompts if equal to true", function() { 1139 // Initialize expected 1140 let expected = [ 1141 ["Upper", "A", "Lower", "a"], 1142 ["Upper", "B", "Lower", "b"], 1143 ["Upper", "C", "Lower", "c"], 1144 ]; 1145 1146 // Call ApplyFilters 1147 let actual = ApplyFilters(vocab2, [{outputIndex:0, inputIndex:1, filters:[]}, {outputIndex:0, inputIndex:1, filters:[{index:2, value:"Noun|Adjective"}]}], {removeDuplicates:true}); 1148 1149 // Assert filtered vocab is correct 1150 expect(actual).to.have.deep.members(expected); 1151 }); 1152 }); 1153 }); 1154 1155 describe("Shuffle method", function() { 1156 it("Should not alter list", function() { 1157 // Initialize list 1158 let list1 = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o"]; // 15 items 1159 1160 // Shuffle list 1161 let list2 = Shuffle(list1); 1162 1163 // Assert list shuffled 1164 expect(list2.length).to.equal(list1.length); 1165 for (let item of list2) { 1166 expect(list1.includes(item)).to.equal(true); 1167 } 1168 }); 1169 }); 1170 });