Update location of test dictionary data
This commit is contained in:
parent
4daf3435c2
commit
a54f44122a
@ -121,7 +121,7 @@ async function clearDatabase() {
|
||||
|
||||
async function testDatabase1() {
|
||||
// Load dictionary data
|
||||
const testDictionary = yomichanTest.createTestDictionaryArchive();
|
||||
const testDictionary = yomichanTest.createTestDictionaryArchive('valid-dictionary1');
|
||||
const testDictionarySource = await testDictionary.generateAsync({type: 'string'});
|
||||
const testDictionaryIndex = JSON.parse(await testDictionary.files['index.json'].async('string'));
|
||||
|
||||
@ -800,7 +800,7 @@ async function testFindTagForTitle1(database, title) {
|
||||
|
||||
async function testDatabase2() {
|
||||
// Load dictionary data
|
||||
const testDictionary = yomichanTest.createTestDictionaryArchive();
|
||||
const testDictionary = yomichanTest.createTestDictionaryArchive('valid-dictionary1');
|
||||
const testDictionarySource = await testDictionary.generateAsync({type: 'string'});
|
||||
const testDictionaryIndex = JSON.parse(await testDictionary.files['index.json'].async('string'));
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -26,21 +26,14 @@ function getJSZip() {
|
||||
return JSZip;
|
||||
}
|
||||
|
||||
function createTestDictionaryArchive(dictionaryName) {
|
||||
const fileNames = [
|
||||
'index.json',
|
||||
'tag_bank_1.json',
|
||||
'tag_bank_2.json',
|
||||
'term_bank_1.json',
|
||||
'kanji_bank_1.json',
|
||||
'term_meta_bank_1.json',
|
||||
'kanji_meta_bank_1.json'
|
||||
];
|
||||
function createTestDictionaryArchive(dictionary, dictionaryName) {
|
||||
const dictionaryDirectory = path.join(__dirname, 'data', 'dictionaries', dictionary);
|
||||
const fileNames = fs.readdirSync(dictionaryDirectory);
|
||||
|
||||
const archive = new (getJSZip())();
|
||||
|
||||
for (const fileName of fileNames) {
|
||||
const source = fs.readFileSync(path.join(__dirname, 'test-dictionary-data', fileName), {encoding: 'utf8'});
|
||||
const source = fs.readFileSync(path.join(dictionaryDirectory, fileName), {encoding: 'utf8'});
|
||||
const json = JSON.parse(source);
|
||||
if (fileName === 'index.json' && typeof dictionaryName === 'string') {
|
||||
json.title = dictionaryName;
|
||||
|
Loading…
Reference in New Issue
Block a user