aboutsummaryrefslogtreecommitdiff
path: root/test/yomichan-test.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-11 14:24:03 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-18 21:33:14 -0400
commit5f49f0fed25b421b0142b306a968f2cd435804e1 (patch)
treef6d1a2875f902f07ce9810670725480b6ec305a4 /test/yomichan-test.js
parentac603d54a3a53bec2881199756f3dd6a1aa44057 (diff)
Add tests
Diffstat (limited to 'test/yomichan-test.js')
-rw-r--r--test/yomichan-test.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/yomichan-test.js b/test/yomichan-test.js
index 3351ecdf..0b340abb 100644
--- a/test/yomichan-test.js
+++ b/test/yomichan-test.js
@@ -38,12 +38,17 @@ function createTestDictionaryArchive(dictionary, dictionaryName) {
const archive = new (getJSZip())();
for (const fileName of fileNames) {
- 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;
+ if (/\.json$/.test(fileName)) {
+ 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;
+ }
+ archive.file(fileName, JSON.stringify(json, null, 0));
+ } else {
+ const source = fs.readFileSync(path.join(dictionaryDirectory, fileName), {encoding: null});
+ archive.file(fileName, source);
}
- archive.file(fileName, JSON.stringify(json, null, 0));
}
return archive;