/
githubmirror
/
dayjs
Обзор
Документация
Войти
/
githubmirror
/
dayjs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.10.8
test/plugin.test.js
35 строк
799 B
iamkun
fix: Add UTC mode with UTC plugin (#517)
06 мар 2019, 11:30
Не верифицирован
06 мар 2019, 11:30
caf335c
Код
Авторство
О чём код?
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) })