Skip to content

Commit

Permalink
test: Intl.Segement
Browse files Browse the repository at this point in the history
  • Loading branch information
hotoo committed Nov 12, 2023
1 parent 4007909 commit 8c527b6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const cases: any[] = [
// 英文
[ "a", {
STYLE_NORMAL: [["a"]],
STYLE_PASSPORT: [["a"]],
STYLE_TONE: [["a"]],
STYLE_TONE2: [["a"]],
STYLE_TO3NE: [["a"]],
Expand All @@ -144,6 +145,7 @@ const cases: any[] = [
} ],
[ "aa", {
STYLE_NORMAL: [["aa"]],
STYLE_PASSPORT: [["aa"]],
STYLE_TONE: [["aa"]],
STYLE_TONE2: [["aa"]],
STYLE_TO3NE: [["aa"]],
Expand All @@ -152,6 +154,7 @@ const cases: any[] = [
} ],
[ "a a", {
STYLE_NORMAL: [["a a"]],
STYLE_PASSPORT: [["a a"]],
STYLE_TONE: [["a a"]],
STYLE_TONE2: [["a a"]],
STYLE_TO3NE: [["a a"]],
Expand All @@ -160,6 +163,7 @@ const cases: any[] = [
} ],
[ "一 一", {
STYLE_NORMAL: [["yi"], [" "], ["yi"]],
STYLE_PASSPORT: [["YI"], [" "], ["YI"]],
STYLE_TONE: [["yī"], [" "], ["yī"]],
STYLE_TONE2: [["yi1"], [" "], ["yi1"]],
STYLE_TO3NE: [["yi1"], [" "], ["yi1"]],
Expand All @@ -170,6 +174,7 @@ const cases: any[] = [
// 中英混合
[ "拼音(pinyin)", {
STYLE_NORMAL: [["pin"], ["yin"], ["(pinyin)"]],
STYLE_PASSPORT: [["PIN"], ["YIN"], ["(pinyin)"]],
STYLE_TONE: [["pīn"], ["yīn"], ["(pinyin)"]],
STYLE_TONE2: [["pin1"], ["yin1"], ["(pinyin)"]],
STYLE_TO3NE: [["pi1n"], ["yi1n"], ["(pinyin)"]],
Expand All @@ -180,6 +185,7 @@ const cases: any[] = [
// 中英混合,多音字,单音词。
[ "中国(china)", {
STYLE_NORMAL: [["zhong"], ["guo"], ["(china)"]],
STYLE_PASSPORT: [["ZHONG"], ["GUO"], ["(china)"]],
STYLE_TONE: {
normal: [["zhōng", "zhòng"], ["guó"], ["(china)"]],
segment: [["zhōng"], ["guó"], ["(china)"]],
Expand All @@ -205,6 +211,10 @@ const cases: any[] = [
normal: [["páng", "fǎng"], ["huáng"]],
segment: [["páng"], ["huáng"]],
},
STYLE_PASSPORT: {
normal: [["PANG", "FANG"], ["HUANG"]],
segment: [["PANG"], ["HUANG"]],
},
STYLE_TONE2: {
normal: [["pang2", "fang3"], ["huang2"]],
segment: [["pang2"], ["huang2"]],
Expand All @@ -226,6 +236,7 @@ const cases: any[] = [
// 中英混合,多音字,单音词。
[ "0套价", {
STYLE_NORMAL: [["0"], ["tao"], ["jia", "jie"]],
STYLE_PASSPORT: [["0"], ["TAO"], ["JIA", "JIE"]],
STYLE_TONE: [["0"], ["tào"], ["jià", "jiè", "jie"]],
STYLE_TONE2: [["0"], ["tao4"], ["jia4", "jie4", "jie"]],
STYLE_TO3NE: [["0"], ["ta4o"], ["jia4", "jie4", "jie"]],
Expand All @@ -239,6 +250,10 @@ const cases: any[] = [
normal: [["nv", "ru"], ["liu"], ["mang", "meng"]],
segment: [["nv", "ru"], ["liu"], ["mang"]],
},
STYLE_PASSPORT: {
normal: [["NYU", "RU"], ["LIU"], ["MANG", "MENG"]],
segment: [["NYU", "RU"], ["LIU"], ["MANG"]],
},
STYLE_TONE: {
normal: [["nǚ", "rǔ"], ["liú"], ["máng", "méng"]],
segment: [["nǚ", "rǔ"], ["liú"], ["máng"]],
Expand Down Expand Up @@ -273,6 +288,7 @@ describe("姓名模式", function() {
it("单姓", function() {
expect(pinyin("华夫人", { mode: "NORMAL"})).toEqual([["huá"], ["fū"], ["rén"]]);
expect(pinyin("华夫人", { mode: "SURNAME"})).toEqual([["huà"], ["fū"], ["rén"]]);
expect(pinyin("吕布", { mode: "SURNAME", style: "passport" })).toEqual([["LYU"], ["BU"]]);
});
});

Expand Down

0 comments on commit 8c527b6

Please sign in to comment.