-
-
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.
- Add functions to generate correct noun for time periods (based on `cs.js`); - Add `sk.test.js` (based on `cs.test.js`); - Fix a comment in `cs.test.js`.
- Loading branch information
ITEnS
committed
Mar 12, 2020
1 parent
f9b8945
commit f54861a
Showing
3 changed files
with
121 additions
and
20 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
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
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,52 @@ | ||
import moment from 'moment' | ||
import MockDate from 'mockdate' | ||
import dayjs from '../../src' | ||
import relativeTime from '../../src/plugin/relativeTime' | ||
import '../../src/locale/sk' | ||
|
||
dayjs.extend(relativeTime) | ||
|
||
beforeEach(() => { | ||
MockDate.set(new Date()) | ||
}) | ||
|
||
afterEach(() => { | ||
MockDate.reset() | ||
}) | ||
|
||
it('RelativeTime: Time from X', () => { | ||
const T = [ | ||
[44.4, 'second'], // a few seconds | ||
[89.5, 'second'], // a minute | ||
[2, 'minute'], // 2 minutes | ||
[43, 'minute'], // 43 minutes | ||
[45, 'minute'], // an hour | ||
[3, 'hour'], // 3 hours | ||
[21, 'hour'], // 21 hours | ||
[1, 'day'], // a day | ||
[3, 'day'], // 3 day | ||
[25, 'day'], // 25 days | ||
[1, 'month'], // a month | ||
[2, 'month'], // 2 month | ||
[10, 'month'], // 10 month | ||
[1, 'year'], // a year | ||
[2, 'year'], // 2 year | ||
[5, 'year'], // 5 year | ||
[18, 'month'] // 2 years | ||
] | ||
|
||
T.forEach((t) => { | ||
dayjs.locale('sk') | ||
moment.locale('sk') | ||
const dayjsDay = dayjs() | ||
const momentDay = moment() | ||
const dayjsCompare = dayjs().add(t[0], t[1]) | ||
const momentCompare = moment().add(t[0], t[1]) | ||
expect(dayjsDay.from(dayjsCompare)) | ||
.toBe(momentDay.from(momentCompare)) | ||
expect(dayjsDay.to(dayjsCompare)) | ||
.toBe(momentDay.to(momentCompare)) | ||
expect(dayjsDay.from(dayjsCompare, true)) | ||
.toBe(momentDay.from(momentCompare, true)) | ||
}) | ||
}) |