/
githubmirror
/
dayjs
Обзор
Документация
Войти
/
githubmirror
/
dayjs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
test/locale/br.test.js
54 строки
2 KB
Jean-Baptiste Le Duigou
fix: update Breton [br] locale relativeTime config (#1103)
13 окт 2020, 11:31
Не верифицирован
13 окт 2020, 11:31
b038bfd
Код
Авторство
О чём код?
import moment from 'moment' import MockDate from 'mockdate' import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import '../../src/locale/br' dayjs.extend(relativeTime) beforeEach(() => { MockDate.set(new Date()) }) afterEach(() => { MockDate.reset() }) it('Format Month with locale function', () => { for (let i = 0; i <= 7; i += 1) { const dayjsBR = dayjs().locale('br').add(i, 'day') const momentBR = moment().locale('br').add(i, 'day') const testFormat1 = 'DD MMMM YYYY MMM' const testFormat2 = 'MMMM' const testFormat3 = 'MMM' expect(dayjsBR.format(testFormat1)).toEqual(momentBR.format(testFormat1)) expect(dayjsBR.format(testFormat2)).toEqual(momentBR.format(testFormat2)) expect(dayjsBR.format(testFormat3)).toEqual(momentBR.format(testFormat3)) } }) 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('br') moment.locale('br') 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)) }) })