-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add Japanese locale unit tests (#1280)
- Loading branch information
1 parent
f2e4790
commit f9d79d5
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import MockDate from 'mockdate' | ||
import moment from 'moment' | ||
import dayjs from '../../src' | ||
import relativeTime from '../../src/plugin/relativeTime' | ||
import '../../src/locale/ja' | ||
|
||
dayjs.extend(relativeTime) | ||
|
||
beforeEach(() => { | ||
MockDate.set(new Date()) | ||
}) | ||
|
||
afterEach(() => { | ||
MockDate.reset() | ||
}) | ||
|
||
it('Finnish locale relative time in past and future', () => { | ||
const cases = [ | ||
[1, 'd', '1日後'], | ||
[-1, 'd', '1日前'], | ||
[2, 'd', '2日後'], | ||
[-2, 'd', '2日前'], | ||
[10, 'd', '10日後'], | ||
[-10, 'd', '10日前'], | ||
[6, 'm', '6分後'], | ||
[-6, 'm', '6分前'], | ||
[5, 'h', '5時間後'], | ||
[-5, 'h', '5時間前'], | ||
[3, 'M', '3ヶ月後'], | ||
[-3, 'M', '3ヶ月前'], | ||
[4, 'y', '4年後'], | ||
[-4, 'y', '4年前'] | ||
] | ||
cases.forEach((c) => { | ||
expect(dayjs().add(c[0], c[1]).locale('ja').fromNow()) | ||
.toBe(c[2]) | ||
expect(dayjs().add(c[0], c[1]).locale('ja').fromNow()) | ||
.toBe(moment().add(c[0], c[1]).locale('ja').fromNow()) | ||
}) | ||
expect(dayjs().add(-10, 'd').locale('ja').fromNow(true)) | ||
.toBe('10日') | ||
expect(dayjs().add(-10, 'd').locale('ja').fromNow(true)) | ||
.toBe(moment().add(-10, 'd').locale('ja').fromNow(true)) | ||
}) | ||
|