From a54f44122a3a245c1b1579c15b2faf9d50c15c55 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 22 Feb 2020 12:58:33 -0500 Subject: Update location of test dictionary data --- test/test-dictionary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/test-dictionary.js') diff --git a/test/test-dictionary.js b/test/test-dictionary.js index 84014540..b9885edc 100644 --- a/test/test-dictionary.js +++ b/test/test-dictionary.js @@ -3,7 +3,7 @@ const dictionaryValidate = require('./dictionary-validate'); async function main() { - const archive = yomichanTest.createTestDictionaryArchive(); + const archive = yomichanTest.createTestDictionaryArchive('valid-dictionary1'); const schemas = dictionaryValidate.getSchemas(); await dictionaryValidate.validateDictionary(archive, schemas); } -- cgit v1.2.3 From a2b72dd3ab4a560d4549aa52912fcb9cd9f275ab Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 22 Feb 2020 13:40:57 -0500 Subject: Update test-dictionary --- test/test-dictionary.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'test/test-dictionary.js') diff --git a/test/test-dictionary.js b/test/test-dictionary.js index b9885edc..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('valid-dictionary1'); + 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`); + } + } + } } -- cgit v1.2.3