Skip to content

Commit

Permalink
test: add tests for more languages
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed Apr 21, 2023
1 parent e657543 commit c4e0c07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/languages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { JAVANESE_UNICODE_RANGE } from "./javanese";
import { KHMER_UNICODE_RANGE } from "./khmer";
import { LAO_UNICODE_RANGE } from "./lao";
import { THAI_UNICODE_RANGE } from "./thai";
import { VAI_UNICODE_RANGE } from "./vai";

export const UNICODE_RANGES: UnicodeRange = [
...THAI_UNICODE_RANGE,
...LAO_UNICODE_RANGE,
...BURMESE_UNICODE_RANGE,
...KHMER_UNICODE_RANGE,
...JAVANESE_UNICODE_RANGE,
...VAI_UNICODE_RANGE,
...CJK_UNICODE_RANGES,
];
12 changes: 12 additions & 0 deletions tests/words.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,15 @@ test("chinese text", () => {
test("chinese text with punctuation & whitespace", () => {
expect(countWords("夫未战而庙算胜者,得算多也")).toBe(12);
});

const languages = {
khmer: [`អ្នក​សុខសប្បាយ​ទេ`, 15],
thai: [`สบายดีไหม`, 9],
lao: [`ສະ​ບາຍ​ດີ​ບໍ?`, 9],
};
for (let lang in languages) {
test(`${lang} text`, () => {
const [text, expected] = languages[lang];
expect(countWords(text)).toBe(expected);
});
}

0 comments on commit c4e0c07

Please sign in to comment.