deno.land / x / dayjs@v1.11.5 / test / plugin / weekday.test.js

weekday.test.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import MockDate from 'mockdate'import moment from 'moment'import dayjs from '../../src'import weekday from '../../src/plugin/weekday'import '../../src/locale/zh-cn'import '../../src/locale/ar'
dayjs.extend(weekday)
beforeEach(() => { MockDate.set(new Date())})
afterEach(() => { MockDate.reset() moment.locale('en') dayjs.locale('en')})
it('Sunday is the first day of the week', () => { expect(dayjs().weekday()).toBe(moment().weekday()) expect(dayjs().weekday(0).date()).toBe(moment().weekday(0).date()) expect(dayjs().weekday(-7).format()).toBe(moment().weekday(-7).format()) expect(dayjs().weekday(7).format()).toBe(moment().weekday(7).format())})
it('Monday is the first day of the week', () => { moment.locale('zh-cn') dayjs.locale('zh-cn') expect(dayjs().weekday()).toBe(moment().weekday()) expect(dayjs().weekday(0).date()).toBe(moment().weekday(0).date()) expect(dayjs().weekday(-7).format()).toBe(moment().weekday(-7).format()) expect(dayjs().weekday(7).format()).toBe(moment().weekday(7).format()) const d1 = '2020-01-05' expect(dayjs(d1).weekday()).toBe(moment(d1).weekday()) const d2 = '2020-01-07' expect(dayjs(d2).weekday()).toBe(moment(d2).weekday())})
it('Saturday is the first day of the week', () => { moment.locale('ar') dayjs.locale('ar') expect(dayjs().weekday()).toBe(moment().weekday()) expect(dayjs().weekday(0).date()).toBe(moment().weekday(0).date()) expect(dayjs().weekday(-7).valueOf()).toBe(moment().weekday(-7).valueOf()) expect(dayjs().weekday(7).valueOf()).toBe(moment().weekday(7).valueOf())})
dayjs

Version Info

Tagged at
a year ago