diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-22 14:34:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-22 14:34:20 -0500 |
commit | f3c4b0e1e14cbdfb86c692e89144c762801b2339 (patch) | |
tree | e7e77fca7b151c1f9a17ab5a1314589a5578dd28 /test/test-dictionary.js | |
parent | 0e31139734efd51799efcb6357c074059c78858d (diff) | |
parent | a2b72dd3ab4a560d4549aa52912fcb9cd9f275ab (diff) |
Merge pull request #369 from toasted-nutbread/dictionary-validation
Dictionary validation
Diffstat (limited to 'test/test-dictionary.js')
-rw-r--r-- | test/test-dictionary.js | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/test/test-dictionary.js b/test/test-dictionary.js index 84014540..b157dd5d 100644 --- a/test/test-dictionary.js +++ b/test/test-dictionary.js @@ -3,9 +3,38 @@ const dictionaryValidate = require('./dictionary-validate'); async function main() { - const archive = yomichanTest.createTestDictionaryArchive(); + const dictionaries = [ + {name: 'valid-dictionary1', valid: true}, + {name: 'invalid-dictionary1', valid: false}, + {name: 'invalid-dictionary2', valid: false}, + {name: 'invalid-dictionary3', valid: false}, + {name: 'invalid-dictionary4', valid: false}, + {name: 'invalid-dictionary5', valid: false}, + {name: 'invalid-dictionary6', valid: false} + ]; + const schemas = dictionaryValidate.getSchemas(); - await dictionaryValidate.validateDictionary(archive, schemas); + + for (const {name, valid} of dictionaries) { + const archive = yomichanTest.createTestDictionaryArchive(name); + + let error = null; + try { + await dictionaryValidate.validateDictionary(archive, schemas); + } catch (e) { + error = e; + } + + if (valid) { + if (error !== null) { + throw error; + } + } else { + if (error === null) { + throw new Error(`Expected dictionary ${name} to be invalid`); + } + } + } } |