Skip to content

Commit

Permalink
fix: update es es-do locale adding weekStart && update weekStart test
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed Feb 5, 2019
1 parent 1295591 commit 66e42ec
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "index.d.ts",
"module": "./src/index.js",
"scripts": {
"test": "jest && TZ=Pacific/Auckland npm run test-tz && TZ=Europe/London npm run test-tz && npm run test-tz",
"test": "TZ=Pacific/Auckland npm run test-tz && TZ=Europe/London npm run test-tz && npm run test-tz && jest",
"test-tz": "jest test/timezone.test --coverage=false",
"lint": "./node_modules/.bin/eslint src/* test/* build/*",
"build": "cross-env BABEL_ENV=build node build && npm run size",
Expand Down
1 change: 1 addition & 0 deletions src/locale/es-do.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const locale = {
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
monthsShort: 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'),
weekStart: 1,
relativeTime: {
future: 'en %s',
past: 'hace %s',
Expand Down
1 change: 1 addition & 0 deletions src/locale/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const locale = {
weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
weekStart: 1,
formats: {
LT: 'H:mm',
LTS: 'H:mm:ss',
Expand Down
4 changes: 3 additions & 1 deletion test/locale/keys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ it('Locale keys', () => {
relativeTime,
weekdaysShort,
monthsShort,
weekdaysMin
weekdaysMin,
weekStart
} = l
expect(name).toEqual(expect.any(String))
expect(weekdays).toEqual(expect.any(Array))

if (weekdaysShort) expect(weekdaysShort).toEqual(expect.any(Array))
if (monthsShort) expect(monthsShort).toEqual(expect.any(Array))
if (weekdaysMin) expect(weekdaysMin).toEqual(expect.any(Array))
if (weekStart) expect(weekStart).toEqual(expect.any(Number))

expect(months).toEqual(expect.any(Array))
// function pass date return string or number or null
Expand Down
7 changes: 6 additions & 1 deletion test/manipulate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import moment from 'moment'
import MockDate from 'mockdate'
import dayjs from '../src'
import '../src/locale/zh-cn'
import '../src/locale/ar'

beforeEach(() => {
MockDate.set(new Date())
Expand Down Expand Up @@ -31,7 +32,11 @@ describe('StartOf EndOf', () => {
})

it('StartOf week with locale', () => {
expect(dayjs().locale('zh-cn').startOf('week').format()).toBe(moment().locale('zh-cn').startOf('week').format())
const testArr = ['zh-cn']
testArr.forEach((l) => {
expect(dayjs().locale(l).startOf('week').date()).toBe(moment().locale(l).startOf('week').date())
expect(dayjs().locale(l).endOf('week').date()).toBe(moment().locale(l).endOf('week').date())
})
})
})

Expand Down

0 comments on commit 66e42ec

Please sign in to comment.