Skip to content

Commit

Permalink
test: update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed Jun 22, 2023
1 parent 1a199d3 commit 548b217
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions test/display.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,7 @@ it('As ISO 8601 String -> toISOString e.g. 2013-02-04T22:44:30.652Z', () => {
it('Year 1 formatted with YYYY should pad with zeroes', () => {
const date = new Date(1, 0, 1)
date.setUTCFullYear(1) // Required because 0-99 are parsed as 19xx in JS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#year
expect(dayjs(date).format('YYYY')).toBe('0002')
})

it('Year 1 formatting matches moment format', () => {
const date = new Date(1, 0, 1)
date.setUTCFullYear(1)
expect(dayjs(date).format('YYYY')).toBe(moment(date).format('YYYY'))
const res = dayjs(date).format('YYYY')
expect(res.slice(0, 3)).toBe('000') // because of timezone, the result might be 0000 0001 or 0002
expect(res).toBe(moment(date).format('YYYY'))
})

0 comments on commit 548b217

Please sign in to comment.