-
-
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.
Merge pull request #1350 from iamkun/dev
D2M
- Loading branch information
Showing
12 changed files
with
275 additions
and
44 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
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
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,71 @@ | ||
import moment from 'moment' | ||
import MockDate from 'mockdate' | ||
import dayjs from '../../src' | ||
import relativeTime from '../../src/plugin/relativeTime' | ||
import localeData from '../../src/plugin/localeData' | ||
import preParsePostFormat from '../../src/plugin/preParsePostFormat' | ||
import '../../src/locale/bn' | ||
|
||
dayjs.extend(localeData) | ||
dayjs.extend(relativeTime) | ||
dayjs.extend(preParsePostFormat) | ||
|
||
beforeEach(() => { | ||
MockDate.set(new Date()) | ||
}) | ||
|
||
afterEach(() => { | ||
MockDate.reset() | ||
}) | ||
|
||
it('Format Month with locale function', () => { | ||
for (let i = 0; i <= 7; i += 1) { | ||
const dayjsBN = dayjs() | ||
.locale('bn') | ||
.add(i, 'day') | ||
const momentBN = moment() | ||
.locale('bn') | ||
.add(i, 'day') | ||
const testFormat1 = 'DD MMMM YYYY MMM' | ||
const testFormat2 = 'MMMM' | ||
const testFormat3 = 'MMM' | ||
expect(dayjsBN.format(testFormat1)).toEqual(momentBN.format(testFormat1)) | ||
expect(dayjsBN.format(testFormat2)).toEqual(momentBN.format(testFormat2)) | ||
expect(dayjsBN.format(testFormat3)).toEqual(momentBN.format(testFormat3)) | ||
} | ||
}) | ||
|
||
it('Preparse with locale function', () => { | ||
for (let i = 0; i <= 7; i += 1) { | ||
dayjs.locale('bn') | ||
const momentBN = moment() | ||
.locale('bn') | ||
.add(i, 'day') | ||
expect(dayjs(momentBN.format()).format()).toEqual(momentBN.format()) | ||
} | ||
}) | ||
|
||
it('RelativeTime: Time from X', () => { | ||
const T = [ | ||
[44.4, 'second'], // a few seconds | ||
[89.5, 'second'], // a minute | ||
[130, 'second'], // two minutes | ||
[43, 'minute'], // 44 minutes | ||
[1, 'hour'], // 1 hour | ||
[21, 'hour'], // 21 hours | ||
[2, 'day'], // 2 days | ||
[25, 'day'], // 25 days | ||
[2, 'month'], // 2 months | ||
[10, 'month'], // 10 months | ||
[18, 'month'], // 2 years | ||
[15, 'year'] // 15 years | ||
] | ||
|
||
T.forEach((t) => { | ||
dayjs.locale('bn') | ||
moment.locale('bn') | ||
expect(dayjs().from(dayjs().add(t[0], t[1]))).toBe(moment().from(moment().add(t[0], t[1]))) | ||
expect(dayjs().from(dayjs().add(t[0], t[1]), true)) | ||
.toBe(moment().from(moment().add(t[0], t[1]), true)) | ||
}) | ||
}) |
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
Oops, something went wrong.