Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 18432x 18432x 18432x 18432x 18432x 9x 9x 9x 1x 1x 1x 9x 9x 9x 9x 9x 9x 108x 108x 9x 9x 9x 9x 9x 9x 9x 9x 9x 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 1x 1x | import assert from "assert"; import { wordlists } from "../index.js"; import { loadTests } from "./utils.js"; import type { TestCaseWordlist } from "./types.js"; describe('Check Wordlists', function() { const tests = loadTests<TestCaseWordlist>("wordlists"); tests.forEach((test) => { let wordlist = wordlists[test.locale]; if (wordlist == null) { return; } it(`matches wordlists: ${ test.locale }`, function() { const words = test.content.split('\n'); let check = ""; for (let i = 0; i < 2048; i++) { let word = wordlist.getWord(i); check += (word + "\n"); assert.equal(word, words[i]); assert.equal(wordlist.getWordIndex(word), i); } assert.equal(check, test.content); }); }); tests.forEach((test) => { let wordlist = wordlists[test.locale]; if (wordlist == null) { return; } it (`splitting and joining are equivalent: ${ test.locale }`, function() { const words: Array<string> = [ ]; for (let i = 0; i < 12; i++) { words.push(wordlist.getWord(i)); } const phrase = wordlist.join(words); const words2 = wordlist.split(phrase); const phrase2 = wordlist.join(words2); assert.deepEqual(words2, words, "split words"); assert.deepEqual(phrase2, phrase, "re-joined words"); }); }); tests.forEach((test) => { let wordlist = wordlists[test.locale]; if (wordlist == null) { return; } it(`handles out-of-range values: ${ test.locale }`, function() { assert.equal(wordlist.getWordIndex("foobar"), -1); assert.throws(() => { wordlist.getWord(-1); }, (error: any) => { return (error.code === "INVALID_ARGUMENT" && error.message.match(/^invalid word index/) && error.argument === "index" && error.value === -1); }); assert.throws(() => { wordlist.getWord(2048); }, (error: any) => { return (error.code === "INVALID_ARGUMENT" && error.message.match(/^invalid word index/) && error.argument === "index" && error.value === 2048); }); }); }); }); |