Skip to content

Commit

Permalink
fix(parse): parse other string throw Invalid date
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed Apr 11, 2018
1 parent 6443b7f commit 4665d0a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Dayjs {
const d = config.substr(6, 2)
return `${y}-${m}-${d}`
}
return false
return config
}

year() {
Expand Down
6 changes: 3 additions & 3 deletions test/manipulate.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import moment from 'moment'
import dayjs from '../src'

test('StartOfYear', () => {
test('StartOf Year', () => {
expect(dayjs().startOf('year').unix()).toBe(moment().startOf('year').unix())
})

test('StartOfMonth', () => {
test('StartOf Month', () => {
expect(dayjs().startOf('month').unix()).toBe(moment().startOf('month').unix())
})

test('StartOfOther', () => {
test('StartOf Other', () => {
expect(dayjs().startOf('otherString').unix()).toBe(moment().startOf('otherString').unix())
})

5 changes: 5 additions & 0 deletions test/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ test('Now', () => {
test('String 20130208', () => {
expect(dayjs('20130208').unix()).toBe(moment('20130208').unix())
})

test('String Other', () => {
global.console.warn = jest.genMockFunction()// moment.js otherString will throw warn
expect(dayjs('otherString').toString().toLowerCase()).toBe(moment('otherString').toString().toLowerCase())
})

0 comments on commit 4665d0a

Please sign in to comment.