Skip to content

Commit

Permalink
add some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
fanmd committed Aug 8, 2022
1 parent cd7b73e commit 92cd141
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/react-intl-universal/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,18 @@ test("Resolve directly if the environment is not browser", async () => {
});
expect(result).toBe(undefined);
});

test("Set default variables locale", () => {
intl.init({ locales, currentLocale: "zh-CN",
defaultVariables:{
company:"Jivation-Group"
}
});
expect(intl.get("COMPANY")).toBe("Jivation-Group是一个国际集团公司");
expect(intl.get("BUSINESS")).toBe("Jivation-Group处理国际性事务");
intl.init({ locales, currentLocale: "en-US", defaultVariables:{
company:"Jivation-Group"
} });
expect(intl.get("COMPANY")).toBe("Jivation-Group is a international group of companies");
expect(intl.get("BUSINESS")).toBe("Jivation-Group handle international business");
});
2 changes: 2 additions & 0 deletions packages/react-intl-universal/test/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ module.exports = ({
"COUPON": "Coupon expires at {expires, time, medium}",
"SALE_PRICE": "The price is {price, number, USD}",
"PHOTO": "You have {num, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}",
"COMPANY":"{company} is a international group of companies",
"BUSINESS":"{company} handle international business",
"NESTED": {
"HELLO": "Hello World",
"HELLO_NAME": "Hello, {name}"
Expand Down
4 changes: 3 additions & 1 deletion packages/react-intl-universal/test/locales/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ module.exports = ({
"COUPON": "优惠卷将在{expires, time, medium}过期",
"TIME": "时间是{theTime, time}",
"SALE_PRICE": "售价{price, number, CNY}",
"PHOTO": "你有{num}张照片"
"PHOTO": "你有{num}张照片",
"COMPANY":"{company}是一个国际集团公司",
"BUSINESS":"{company}处理国际性事务"
});

1 comment on commit 92cd141

@cwtuan
Copy link
Collaborator

@cwtuan cwtuan commented on 92cd141 Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't include personal or company info in test cases..

Please sign in to comment.