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

plugin.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
import MockDate from 'mockdate'import dayjs from '../src'
const testPlugin = (o, c, d) => { c.prototype.newApi = () => ('hello world') d.newFunc = () => ('hi world')}const testPluginWithConfig = (o, c) => { c.prototype.newApiWithConfig = () => (`hello world ${o || ''}`)}
dayjs.extend(testPlugin)dayjs.extend(testPluginWithConfig, 'good')
beforeEach(() => { MockDate.set(new Date())})
afterEach(() => { MockDate.reset()})
it('Plugin extend method and option', () => { expect(dayjs().newApi()).toBe('hello world') expect(dayjs().newApiWithConfig()).toBe('hello world good')})
it('Plugin extend dayjs', () => { expect(dayjs.newFunc()).toBe('hi world')})
it('Plugin use core utils', () => { // u => isUndefined expect(dayjs().$utils().u).toBeInstanceOf(Function)})
dayjs

Version Info

Tagged at
a year ago