pashto-dictionary/functions/src/word-list-maker.test.ts

51 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-08-14 19:30:10 +00:00
import {
psHash,
dePsHash,
PsHash,
} from "./word-list-maker";
import {
Types as T,
} from "@lingdocs/inflect";
const toTest: {
plain: T.PsWord,
hash: PsHash,
}[] = [
{
plain: { p: "کور", f: "kor" },
hash: "کورXkor",
},
{
plain: {
p: "کنار", f: "kanaar",
hyphen: [
{ type: "unwritten", f: "e" },
{ type: "written", f: "daryaab", p: "دریاب" },
],
},
hash: "کنارXkanaar-Xe-دریابXdaryaab",
},
{
plain: {
p: "کار", f: "kaar",
hyphen: [
{ type: "written", f: "U", p: "و" },
{ type: "written", f: "baar", p: "بار" },
],
},
hash: ارXkaar-وXU-بارXbaar",
},
];
test("psHash should work", () => {
toTest.forEach((t) => {
expect(psHash(t.plain)).toEqual(t.hash);
});
});
test("dePsHash should work", () => {
toTest.forEach((t) => {
expect(dePsHash(t.hash)).toEqual(t.plain);
});
});