Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed May 21, 2022
1 parent 04d0f34 commit f30b871
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions __test__/main/core/entry.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import entry from "../../../src/main/core/entry";

test("", () => {
const detector = (text: string) => {
if (text[0] == "e") {
return "en";
}
if (text[0] == "j") {
return "ja";
}
if (text[0] == "z") {
return "zh";
}
return "default";
};
const generators = {
ja: (text: string) => {
return text + "(ja)";
},
en: (text: string) => {
return text + "(en)";
},
zh: (text: string) => {
return text + "(zh)";
},
default: (text: string) => {
return text + "(default)";
},
};

const build = entry.build(detector, generators);

expect({ entries: "jaaaaaaaaaaaaaaaaaaaaaaa(ja)", lang: "ja" }).toEqual(build("jaaaaaaaaaaaaaaaaaaaaaaa"));
expect({ entries: "eaaaaaaaaaaaaaaaaaaaaaaa(en)", lang: "en" }).toEqual(build("eaaaaaaaaaaaaaaaaaaaaaaa"));
expect({ entries: "zaaaaaaaaaaaaaaaaaaaaaaa(zh)", lang: "zh" }).toEqual(build("zaaaaaaaaaaaaaaaaaaaaaaa"));
expect({ entries: "Test(default)", lang: "default" }).toEqual(build("Test"));
});

0 comments on commit f30b871

Please sign in to comment.