From 06480751a9d9ff1471455f31e3efc99d552a4975 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 17 Feb 2020 22:31:28 -0500 Subject: Create yomichan-test script to reduce repeated code --- test/yomichan-test.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/yomichan-test.js (limited to 'test/yomichan-test.js') diff --git a/test/yomichan-test.js b/test/yomichan-test.js new file mode 100644 index 00000000..602b8d78 --- /dev/null +++ b/test/yomichan-test.js @@ -0,0 +1,33 @@ +const fs = require('fs'); +const path = require('path'); + + +let JSZip = null; + +function requireScript(fileName, exportNames, variables) { + const absoluteFileName = path.join(__dirname, '..', fileName); + const source = fs.readFileSync(absoluteFileName, {encoding: 'utf8'}); + const exportNamesString = Array.isArray(exportNames) ? exportNames.join(',') : ''; + const variablesArgumentName = '__variables__'; + let variableString = ''; + if (typeof variables === 'object' && variables !== null) { + variableString = Object.keys(variables).join(','); + variableString = `const {${variableString}} = ${variablesArgumentName};`; + } + return Function(variablesArgumentName, `'use strict';${variableString}${source}\n;return {${exportNamesString}};`)(variables); +} + +function getJSZip() { + if (JSZip === null) { + process.noDeprecation = true; // Suppress a warning about JSZip + JSZip = require(path.join(__dirname, '../ext/mixed/lib/jszip.min.js')); + process.noDeprecation = false; + } + return JSZip; +} + + +module.exports = { + requireScript, + get JSZip() { return getJSZip(); } +}; -- cgit v1.2.3 From 09ea007883360589d8b5aeb72ddb75eb126ce595 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 18 Feb 2020 22:19:08 -0500 Subject: Add test dictionary data --- test/test-dictionary-data/index.json | 6 ++++ test/test-dictionary-data/kanji_bank_1.json | 42 ++++++++++++++++++++++++ test/test-dictionary-data/kanji_meta_bank_1.json | 4 +++ test/test-dictionary-data/tag_bank_1.json | 7 ++++ test/test-dictionary-data/tag_bank_2.json | 9 +++++ test/test-dictionary-data/term_bank_1.json | 34 +++++++++++++++++++ test/test-dictionary-data/term_meta_bank_1.json | 5 +++ test/yomichan-test.js | 26 +++++++++++++++ 8 files changed, 133 insertions(+) create mode 100644 test/test-dictionary-data/index.json create mode 100644 test/test-dictionary-data/kanji_bank_1.json create mode 100644 test/test-dictionary-data/kanji_meta_bank_1.json create mode 100644 test/test-dictionary-data/tag_bank_1.json create mode 100644 test/test-dictionary-data/tag_bank_2.json create mode 100644 test/test-dictionary-data/term_bank_1.json create mode 100644 test/test-dictionary-data/term_meta_bank_1.json (limited to 'test/yomichan-test.js') diff --git a/test/test-dictionary-data/index.json b/test/test-dictionary-data/index.json new file mode 100644 index 00000000..3034bf38 --- /dev/null +++ b/test/test-dictionary-data/index.json @@ -0,0 +1,6 @@ +{ + "title": "Test Dictionary", + "format": 3, + "revision": "test", + "sequenced": true +} \ No newline at end of file diff --git a/test/test-dictionary-data/kanji_bank_1.json b/test/test-dictionary-data/kanji_bank_1.json new file mode 100644 index 00000000..264f94c1 --- /dev/null +++ b/test/test-dictionary-data/kanji_bank_1.json @@ -0,0 +1,42 @@ +[ + [ + "打", + "ダ ダアス", + "う.つ う.ち- ぶ.つ", + "ktag1 ktag2", + [ + "meaning1", + "meaning2", + "meaning3", + "meaning4", + "meaning5" + ], + { + "kstat1": "1", + "kstat2": "2", + "kstat3": "3", + "kstat4": "4", + "kstat5": "5" + } + ], + [ + "込", + "", + "-こ.む こ.む こ.み -こ.み こ.める", + "ktag1 ktag2", + [ + "meaning1", + "meaning2", + "meaning3", + "meaning4", + "meaning5" + ], + { + "kstat1": "1", + "kstat2": "2", + "kstat3": "3", + "kstat4": "4", + "kstat5": "5" + } + ] +] \ No newline at end of file diff --git a/test/test-dictionary-data/kanji_meta_bank_1.json b/test/test-dictionary-data/kanji_meta_bank_1.json new file mode 100644 index 00000000..73e75b8a --- /dev/null +++ b/test/test-dictionary-data/kanji_meta_bank_1.json @@ -0,0 +1,4 @@ +[ + ["打", "freq", 1], + ["込", "freq", 2] +] \ No newline at end of file diff --git a/test/test-dictionary-data/tag_bank_1.json b/test/test-dictionary-data/tag_bank_1.json new file mode 100644 index 00000000..109ad395 --- /dev/null +++ b/test/test-dictionary-data/tag_bank_1.json @@ -0,0 +1,7 @@ +[ + ["tag1", "category1", 0, "tag1 notes", 0], + ["tag2", "category2", 0, "tag2 notes", 0], + ["tag3", "category3", 0, "tag3 notes", 0], + ["tag4", "category4", 0, "tag4 notes", 0], + ["tag5", "category5", 0, "tag5 notes", 0] +] \ No newline at end of file diff --git a/test/test-dictionary-data/tag_bank_2.json b/test/test-dictionary-data/tag_bank_2.json new file mode 100644 index 00000000..5e7936b3 --- /dev/null +++ b/test/test-dictionary-data/tag_bank_2.json @@ -0,0 +1,9 @@ +[ + ["ktag1", "kcategory1", 0, "ktag1 notes", 0], + ["ktag2", "kcategory2", 0, "ktag2 notes", 0], + ["kstat1", "kcategory3", 0, "kstat1 notes", 0], + ["kstat2", "kcategory4", 0, "kstat2 notes", 0], + ["kstat3", "kcategory5", 0, "kstat3 notes", 0], + ["kstat4", "kcategory6", 0, "kstat4 notes", 0], + ["kstat5", "kcategory7", 0, "kstat5 notes", 0] +] \ No newline at end of file diff --git a/test/test-dictionary-data/term_bank_1.json b/test/test-dictionary-data/term_bank_1.json new file mode 100644 index 00000000..755d9f6a --- /dev/null +++ b/test/test-dictionary-data/term_bank_1.json @@ -0,0 +1,34 @@ +[ + ["打", "だ", "tag1 tag2", "", 2, ["definition1a (打, だ)", "definition1b (打, だ)"], 1, "tag3 tag4 tag5"], + ["打", "ダース", "tag1 tag2", "", 1, ["definition1a (打, ダース)", "definition1b (打, ダース)"], 2, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 3, ["definition1a (打つ, うつ)", "definition1b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 4, ["definition2a (打つ, うつ)", "definition2b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 5, ["definition3a (打つ, うつ)", "definition3b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 6, ["definition4a (打つ, うつ)", "definition4b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 7, ["definition5a (打つ, うつ)", "definition5b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 8, ["definition6a (打つ, うつ)", "definition6b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 9, ["definition7a (打つ, うつ)", "definition7b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 10, ["definition8a (打つ, うつ)", "definition8b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 11, ["definition9a (打つ, うつ)", "definition9b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 12, ["definition10a (打つ, うつ)", "definition10b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 13, ["definition11a (打つ, うつ)", "definition11b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 14, ["definition12a (打つ, うつ)", "definition12b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 15, ["definition13a (打つ, うつ)", "definition13b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 16, ["definition14a (打つ, うつ)", "definition14b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 17, ["definition15a (打つ, うつ)", "definition15b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "ぶつ", "tag1 tag2", "v5", 18, ["definition1a (打つ, ぶつ)", "definition1b (打つ, ぶつ)"], 4, "tag3 tag4 tag5"], + ["打つ", "ぶつ", "tag1 tag2", "v5", 19, ["definition2a (打つ, ぶつ)", "definition2b (打つ, ぶつ)"], 4, "tag3 tag4 tag5"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 20, ["definition1a (打ち込む, うちこむ)", "definition1b (打ち込む, うちこむ)"], 5, "tag3 tag4 tag5"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 21, ["definition2a (打ち込む, うちこむ)", "definition2b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 22, ["definition3a (打ち込む, うちこむ)", "definition3b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 23, ["definition4a (打ち込む, うちこむ)", "definition4b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 24, ["definition5a (打ち込む, うちこむ)", "definition5b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 25, ["definition6a (打ち込む, うちこむ)", "definition6b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 26, ["definition7a (打ち込む, うちこむ)", "definition7b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 27, ["definition8a (打ち込む, うちこむ)", "definition8b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 28, ["definition9a (打ち込む, うちこむ)", "definition9b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 29, ["definition1a (打ち込む, ぶちこむ)", "definition1b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"], + ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 30, ["definition2a (打ち込む, ぶちこむ)", "definition2b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"], + ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 31, ["definition3a (打ち込む, ぶちこむ)", "definition3b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"], + ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 32, ["definition4a (打ち込む, ぶちこむ)", "definition4b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"] +] \ No newline at end of file diff --git a/test/test-dictionary-data/term_meta_bank_1.json b/test/test-dictionary-data/term_meta_bank_1.json new file mode 100644 index 00000000..78096502 --- /dev/null +++ b/test/test-dictionary-data/term_meta_bank_1.json @@ -0,0 +1,5 @@ +[ + ["打", "freq", 1], + ["打つ", "freq", 2], + ["打ち込む", "freq", 3] +] \ No newline at end of file diff --git a/test/yomichan-test.js b/test/yomichan-test.js index 602b8d78..dd4da919 100644 --- a/test/yomichan-test.js +++ b/test/yomichan-test.js @@ -26,8 +26,34 @@ 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' + ]; + + const archive = new (getJSZip())(); + + for (const fileName of fileNames) { + const source = fs.readFileSync(path.join(__dirname, 'test-dictionary-data', 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)); + } + + return archive; +} + module.exports = { requireScript, + createTestDictionaryArchive, get JSZip() { return getJSZip(); } }; -- cgit v1.2.3 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 --- .../data/dictionaries/valid-dictionary1/index.json | 6 ++++ .../valid-dictionary1/kanji_bank_1.json | 42 ++++++++++++++++++++++ .../valid-dictionary1/kanji_meta_bank_1.json | 4 +++ .../dictionaries/valid-dictionary1/tag_bank_1.json | 7 ++++ .../dictionaries/valid-dictionary1/tag_bank_2.json | 9 +++++ .../valid-dictionary1/term_bank_1.json | 34 ++++++++++++++++++ .../valid-dictionary1/term_meta_bank_1.json | 5 +++ test/test-database.js | 4 +-- test/test-dictionary-data/index.json | 6 ---- test/test-dictionary-data/kanji_bank_1.json | 42 ---------------------- test/test-dictionary-data/kanji_meta_bank_1.json | 4 --- test/test-dictionary-data/tag_bank_1.json | 7 ---- test/test-dictionary-data/tag_bank_2.json | 9 ----- test/test-dictionary-data/term_bank_1.json | 34 ------------------ test/test-dictionary-data/term_meta_bank_1.json | 5 --- test/test-dictionary.js | 2 +- test/yomichan-test.js | 15 +++----- 17 files changed, 114 insertions(+), 121 deletions(-) create mode 100644 test/data/dictionaries/valid-dictionary1/index.json create mode 100644 test/data/dictionaries/valid-dictionary1/kanji_bank_1.json create mode 100644 test/data/dictionaries/valid-dictionary1/kanji_meta_bank_1.json create mode 100644 test/data/dictionaries/valid-dictionary1/tag_bank_1.json create mode 100644 test/data/dictionaries/valid-dictionary1/tag_bank_2.json create mode 100644 test/data/dictionaries/valid-dictionary1/term_bank_1.json create mode 100644 test/data/dictionaries/valid-dictionary1/term_meta_bank_1.json delete mode 100644 test/test-dictionary-data/index.json delete mode 100644 test/test-dictionary-data/kanji_bank_1.json delete mode 100644 test/test-dictionary-data/kanji_meta_bank_1.json delete mode 100644 test/test-dictionary-data/tag_bank_1.json delete mode 100644 test/test-dictionary-data/tag_bank_2.json delete mode 100644 test/test-dictionary-data/term_bank_1.json delete mode 100644 test/test-dictionary-data/term_meta_bank_1.json (limited to 'test/yomichan-test.js') diff --git a/test/data/dictionaries/valid-dictionary1/index.json b/test/data/dictionaries/valid-dictionary1/index.json new file mode 100644 index 00000000..3034bf38 --- /dev/null +++ b/test/data/dictionaries/valid-dictionary1/index.json @@ -0,0 +1,6 @@ +{ + "title": "Test Dictionary", + "format": 3, + "revision": "test", + "sequenced": true +} \ No newline at end of file diff --git a/test/data/dictionaries/valid-dictionary1/kanji_bank_1.json b/test/data/dictionaries/valid-dictionary1/kanji_bank_1.json new file mode 100644 index 00000000..264f94c1 --- /dev/null +++ b/test/data/dictionaries/valid-dictionary1/kanji_bank_1.json @@ -0,0 +1,42 @@ +[ + [ + "打", + "ダ ダアス", + "う.つ う.ち- ぶ.つ", + "ktag1 ktag2", + [ + "meaning1", + "meaning2", + "meaning3", + "meaning4", + "meaning5" + ], + { + "kstat1": "1", + "kstat2": "2", + "kstat3": "3", + "kstat4": "4", + "kstat5": "5" + } + ], + [ + "込", + "", + "-こ.む こ.む こ.み -こ.み こ.める", + "ktag1 ktag2", + [ + "meaning1", + "meaning2", + "meaning3", + "meaning4", + "meaning5" + ], + { + "kstat1": "1", + "kstat2": "2", + "kstat3": "3", + "kstat4": "4", + "kstat5": "5" + } + ] +] \ No newline at end of file diff --git a/test/data/dictionaries/valid-dictionary1/kanji_meta_bank_1.json b/test/data/dictionaries/valid-dictionary1/kanji_meta_bank_1.json new file mode 100644 index 00000000..73e75b8a --- /dev/null +++ b/test/data/dictionaries/valid-dictionary1/kanji_meta_bank_1.json @@ -0,0 +1,4 @@ +[ + ["打", "freq", 1], + ["込", "freq", 2] +] \ No newline at end of file diff --git a/test/data/dictionaries/valid-dictionary1/tag_bank_1.json b/test/data/dictionaries/valid-dictionary1/tag_bank_1.json new file mode 100644 index 00000000..109ad395 --- /dev/null +++ b/test/data/dictionaries/valid-dictionary1/tag_bank_1.json @@ -0,0 +1,7 @@ +[ + ["tag1", "category1", 0, "tag1 notes", 0], + ["tag2", "category2", 0, "tag2 notes", 0], + ["tag3", "category3", 0, "tag3 notes", 0], + ["tag4", "category4", 0, "tag4 notes", 0], + ["tag5", "category5", 0, "tag5 notes", 0] +] \ No newline at end of file diff --git a/test/data/dictionaries/valid-dictionary1/tag_bank_2.json b/test/data/dictionaries/valid-dictionary1/tag_bank_2.json new file mode 100644 index 00000000..5e7936b3 --- /dev/null +++ b/test/data/dictionaries/valid-dictionary1/tag_bank_2.json @@ -0,0 +1,9 @@ +[ + ["ktag1", "kcategory1", 0, "ktag1 notes", 0], + ["ktag2", "kcategory2", 0, "ktag2 notes", 0], + ["kstat1", "kcategory3", 0, "kstat1 notes", 0], + ["kstat2", "kcategory4", 0, "kstat2 notes", 0], + ["kstat3", "kcategory5", 0, "kstat3 notes", 0], + ["kstat4", "kcategory6", 0, "kstat4 notes", 0], + ["kstat5", "kcategory7", 0, "kstat5 notes", 0] +] \ No newline at end of file diff --git a/test/data/dictionaries/valid-dictionary1/term_bank_1.json b/test/data/dictionaries/valid-dictionary1/term_bank_1.json new file mode 100644 index 00000000..755d9f6a --- /dev/null +++ b/test/data/dictionaries/valid-dictionary1/term_bank_1.json @@ -0,0 +1,34 @@ +[ + ["打", "だ", "tag1 tag2", "", 2, ["definition1a (打, だ)", "definition1b (打, だ)"], 1, "tag3 tag4 tag5"], + ["打", "ダース", "tag1 tag2", "", 1, ["definition1a (打, ダース)", "definition1b (打, ダース)"], 2, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 3, ["definition1a (打つ, うつ)", "definition1b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 4, ["definition2a (打つ, うつ)", "definition2b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 5, ["definition3a (打つ, うつ)", "definition3b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 6, ["definition4a (打つ, うつ)", "definition4b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 7, ["definition5a (打つ, うつ)", "definition5b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 8, ["definition6a (打つ, うつ)", "definition6b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 9, ["definition7a (打つ, うつ)", "definition7b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 10, ["definition8a (打つ, うつ)", "definition8b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 11, ["definition9a (打つ, うつ)", "definition9b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 12, ["definition10a (打つ, うつ)", "definition10b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 13, ["definition11a (打つ, うつ)", "definition11b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 14, ["definition12a (打つ, うつ)", "definition12b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 15, ["definition13a (打つ, うつ)", "definition13b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 16, ["definition14a (打つ, うつ)", "definition14b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "うつ", "tag1 tag2", "v5", 17, ["definition15a (打つ, うつ)", "definition15b (打つ, うつ)"], 3, "tag3 tag4 tag5"], + ["打つ", "ぶつ", "tag1 tag2", "v5", 18, ["definition1a (打つ, ぶつ)", "definition1b (打つ, ぶつ)"], 4, "tag3 tag4 tag5"], + ["打つ", "ぶつ", "tag1 tag2", "v5", 19, ["definition2a (打つ, ぶつ)", "definition2b (打つ, ぶつ)"], 4, "tag3 tag4 tag5"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 20, ["definition1a (打ち込む, うちこむ)", "definition1b (打ち込む, うちこむ)"], 5, "tag3 tag4 tag5"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 21, ["definition2a (打ち込む, うちこむ)", "definition2b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 22, ["definition3a (打ち込む, うちこむ)", "definition3b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 23, ["definition4a (打ち込む, うちこむ)", "definition4b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 24, ["definition5a (打ち込む, うちこむ)", "definition5b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 25, ["definition6a (打ち込む, うちこむ)", "definition6b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 26, ["definition7a (打ち込む, うちこむ)", "definition7b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 27, ["definition8a (打ち込む, うちこむ)", "definition8b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "うちこむ", "tag1 tag2", "v5", 28, ["definition9a (打ち込む, うちこむ)", "definition9b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], + ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 29, ["definition1a (打ち込む, ぶちこむ)", "definition1b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"], + ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 30, ["definition2a (打ち込む, ぶちこむ)", "definition2b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"], + ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 31, ["definition3a (打ち込む, ぶちこむ)", "definition3b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"], + ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 32, ["definition4a (打ち込む, ぶちこむ)", "definition4b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"] +] \ No newline at end of file diff --git a/test/data/dictionaries/valid-dictionary1/term_meta_bank_1.json b/test/data/dictionaries/valid-dictionary1/term_meta_bank_1.json new file mode 100644 index 00000000..78096502 --- /dev/null +++ b/test/data/dictionaries/valid-dictionary1/term_meta_bank_1.json @@ -0,0 +1,5 @@ +[ + ["打", "freq", 1], + ["打つ", "freq", 2], + ["打ち込む", "freq", 3] +] \ No newline at end of file diff --git a/test/test-database.js b/test/test-database.js index 801f9925..216ae5dd 100644 --- a/test/test-database.js +++ b/test/test-database.js @@ -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')); diff --git a/test/test-dictionary-data/index.json b/test/test-dictionary-data/index.json deleted file mode 100644 index 3034bf38..00000000 --- a/test/test-dictionary-data/index.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "title": "Test Dictionary", - "format": 3, - "revision": "test", - "sequenced": true -} \ No newline at end of file diff --git a/test/test-dictionary-data/kanji_bank_1.json b/test/test-dictionary-data/kanji_bank_1.json deleted file mode 100644 index 264f94c1..00000000 --- a/test/test-dictionary-data/kanji_bank_1.json +++ /dev/null @@ -1,42 +0,0 @@ -[ - [ - "打", - "ダ ダアス", - "う.つ う.ち- ぶ.つ", - "ktag1 ktag2", - [ - "meaning1", - "meaning2", - "meaning3", - "meaning4", - "meaning5" - ], - { - "kstat1": "1", - "kstat2": "2", - "kstat3": "3", - "kstat4": "4", - "kstat5": "5" - } - ], - [ - "込", - "", - "-こ.む こ.む こ.み -こ.み こ.める", - "ktag1 ktag2", - [ - "meaning1", - "meaning2", - "meaning3", - "meaning4", - "meaning5" - ], - { - "kstat1": "1", - "kstat2": "2", - "kstat3": "3", - "kstat4": "4", - "kstat5": "5" - } - ] -] \ No newline at end of file diff --git a/test/test-dictionary-data/kanji_meta_bank_1.json b/test/test-dictionary-data/kanji_meta_bank_1.json deleted file mode 100644 index 73e75b8a..00000000 --- a/test/test-dictionary-data/kanji_meta_bank_1.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - ["打", "freq", 1], - ["込", "freq", 2] -] \ No newline at end of file diff --git a/test/test-dictionary-data/tag_bank_1.json b/test/test-dictionary-data/tag_bank_1.json deleted file mode 100644 index 109ad395..00000000 --- a/test/test-dictionary-data/tag_bank_1.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - ["tag1", "category1", 0, "tag1 notes", 0], - ["tag2", "category2", 0, "tag2 notes", 0], - ["tag3", "category3", 0, "tag3 notes", 0], - ["tag4", "category4", 0, "tag4 notes", 0], - ["tag5", "category5", 0, "tag5 notes", 0] -] \ No newline at end of file diff --git a/test/test-dictionary-data/tag_bank_2.json b/test/test-dictionary-data/tag_bank_2.json deleted file mode 100644 index 5e7936b3..00000000 --- a/test/test-dictionary-data/tag_bank_2.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - ["ktag1", "kcategory1", 0, "ktag1 notes", 0], - ["ktag2", "kcategory2", 0, "ktag2 notes", 0], - ["kstat1", "kcategory3", 0, "kstat1 notes", 0], - ["kstat2", "kcategory4", 0, "kstat2 notes", 0], - ["kstat3", "kcategory5", 0, "kstat3 notes", 0], - ["kstat4", "kcategory6", 0, "kstat4 notes", 0], - ["kstat5", "kcategory7", 0, "kstat5 notes", 0] -] \ No newline at end of file diff --git a/test/test-dictionary-data/term_bank_1.json b/test/test-dictionary-data/term_bank_1.json deleted file mode 100644 index 755d9f6a..00000000 --- a/test/test-dictionary-data/term_bank_1.json +++ /dev/null @@ -1,34 +0,0 @@ -[ - ["打", "だ", "tag1 tag2", "", 2, ["definition1a (打, だ)", "definition1b (打, だ)"], 1, "tag3 tag4 tag5"], - ["打", "ダース", "tag1 tag2", "", 1, ["definition1a (打, ダース)", "definition1b (打, ダース)"], 2, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 3, ["definition1a (打つ, うつ)", "definition1b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 4, ["definition2a (打つ, うつ)", "definition2b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 5, ["definition3a (打つ, うつ)", "definition3b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 6, ["definition4a (打つ, うつ)", "definition4b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 7, ["definition5a (打つ, うつ)", "definition5b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 8, ["definition6a (打つ, うつ)", "definition6b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 9, ["definition7a (打つ, うつ)", "definition7b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 10, ["definition8a (打つ, うつ)", "definition8b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 11, ["definition9a (打つ, うつ)", "definition9b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 12, ["definition10a (打つ, うつ)", "definition10b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 13, ["definition11a (打つ, うつ)", "definition11b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 14, ["definition12a (打つ, うつ)", "definition12b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 15, ["definition13a (打つ, うつ)", "definition13b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 16, ["definition14a (打つ, うつ)", "definition14b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "うつ", "tag1 tag2", "v5", 17, ["definition15a (打つ, うつ)", "definition15b (打つ, うつ)"], 3, "tag3 tag4 tag5"], - ["打つ", "ぶつ", "tag1 tag2", "v5", 18, ["definition1a (打つ, ぶつ)", "definition1b (打つ, ぶつ)"], 4, "tag3 tag4 tag5"], - ["打つ", "ぶつ", "tag1 tag2", "v5", 19, ["definition2a (打つ, ぶつ)", "definition2b (打つ, ぶつ)"], 4, "tag3 tag4 tag5"], - ["打ち込む", "うちこむ", "tag1 tag2", "v5", 20, ["definition1a (打ち込む, うちこむ)", "definition1b (打ち込む, うちこむ)"], 5, "tag3 tag4 tag5"], - ["打ち込む", "うちこむ", "tag1 tag2", "v5", 21, ["definition2a (打ち込む, うちこむ)", "definition2b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], - ["打ち込む", "うちこむ", "tag1 tag2", "v5", 22, ["definition3a (打ち込む, うちこむ)", "definition3b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], - ["打ち込む", "うちこむ", "tag1 tag2", "v5", 23, ["definition4a (打ち込む, うちこむ)", "definition4b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], - ["打ち込む", "うちこむ", "tag1 tag2", "v5", 24, ["definition5a (打ち込む, うちこむ)", "definition5b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], - ["打ち込む", "うちこむ", "tag1 tag2", "v5", 25, ["definition6a (打ち込む, うちこむ)", "definition6b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], - ["打ち込む", "うちこむ", "tag1 tag2", "v5", 26, ["definition7a (打ち込む, うちこむ)", "definition7b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], - ["打ち込む", "うちこむ", "tag1 tag2", "v5", 27, ["definition8a (打ち込む, うちこむ)", "definition8b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], - ["打ち込む", "うちこむ", "tag1 tag2", "v5", 28, ["definition9a (打ち込む, うちこむ)", "definition9b (打ち込む, うちこむ)"], 5, "tag5 tag6 tag7"], - ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 29, ["definition1a (打ち込む, ぶちこむ)", "definition1b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"], - ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 30, ["definition2a (打ち込む, ぶちこむ)", "definition2b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"], - ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 31, ["definition3a (打ち込む, ぶちこむ)", "definition3b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"], - ["打ち込む", "ぶちこむ", "tag1 tag2", "v5", 32, ["definition4a (打ち込む, ぶちこむ)", "definition4b (打ち込む, ぶちこむ)"], 6, "tag3 tag4 tag5"] -] \ No newline at end of file diff --git a/test/test-dictionary-data/term_meta_bank_1.json b/test/test-dictionary-data/term_meta_bank_1.json deleted file mode 100644 index 78096502..00000000 --- a/test/test-dictionary-data/term_meta_bank_1.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - ["打", "freq", 1], - ["打つ", "freq", 2], - ["打ち込む", "freq", 3] -] \ No newline at end of file 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); } diff --git a/test/yomichan-test.js b/test/yomichan-test.js index dd4da919..939e0ad2 100644 --- a/test/yomichan-test.js +++ b/test/yomichan-test.js @@ -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; -- cgit v1.2.3 From d87050bbbba6edb64f75e65b614526a3beef9105 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 23 Feb 2020 13:05:48 -0500 Subject: Add missing copyright headers --- test/dictionary-validate.js | 18 ++++++++++++++++++ test/schema-validate.js | 18 ++++++++++++++++++ test/test-database.js | 18 ++++++++++++++++++ test/test-dictionary.js | 18 ++++++++++++++++++ test/test-schema.js | 18 ++++++++++++++++++ test/yomichan-test.js | 18 ++++++++++++++++++ 6 files changed, 108 insertions(+) (limited to 'test/yomichan-test.js') diff --git a/test/dictionary-validate.js b/test/dictionary-validate.js index 25a5de88..14eee2ed 100644 --- a/test/dictionary-validate.js +++ b/test/dictionary-validate.js @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2020 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + const fs = require('fs'); const path = require('path'); const yomichanTest = require('./yomichan-test'); diff --git a/test/schema-validate.js b/test/schema-validate.js index 1271a611..a4f2d94c 100644 --- a/test/schema-validate.js +++ b/test/schema-validate.js @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2020 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + const fs = require('fs'); const yomichanTest = require('./yomichan-test'); diff --git a/test/test-database.js b/test/test-database.js index add04a03..c2317881 100644 --- a/test/test-database.js +++ b/test/test-database.js @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2020 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + const fs = require('fs'); const url = require('url'); const path = require('path'); diff --git a/test/test-dictionary.js b/test/test-dictionary.js index b157dd5d..74f9e62b 100644 --- a/test/test-dictionary.js +++ b/test/test-dictionary.js @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2020 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + const yomichanTest = require('./yomichan-test'); const dictionaryValidate = require('./dictionary-validate'); diff --git a/test/test-schema.js b/test/test-schema.js index 8ca63167..f4612f86 100644 --- a/test/test-schema.js +++ b/test/test-schema.js @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2020 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + const assert = require('assert'); const yomichanTest = require('./yomichan-test'); diff --git a/test/yomichan-test.js b/test/yomichan-test.js index 939e0ad2..78bfb9c6 100644 --- a/test/yomichan-test.js +++ b/test/yomichan-test.js @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2020 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + const fs = require('fs'); const path = require('path'); -- cgit v1.2.3