Update test-dictionary
This commit is contained in:
parent
12e0923b63
commit
a2b72dd3ab
@ -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();
|
||||
|
||||
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`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user