Skip to content

Commit

Permalink
add tests for REGEX_PARSE
Browse files Browse the repository at this point in the history
includes two tests that would have matched before fix iamkun#1239 but no longer match
  • Loading branch information
bcurtin144 authored Jan 2, 2021
1 parent 17724a5 commit cfcf088
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,34 @@ describe('REGEX_PARSE', () => {
expect(dayjs(date).valueOf()).toBe(moment(date).valueOf())
expect(d.join('-')).toBe('2019-03-25T06:41:00.999999999-2019-03-25-06-41-00-999999999')
})
it('20210102T012345', () => {
const date = '20210102T012345'
const d = date.match(REGEX_PARSE)
expect(dayjs(date).valueOf()).toBe(moment(date).valueOf())
expect(d.join('-')).toBe('20210102T012345-2021-01-02-01-23-45-')
})
it('2021-01-02T01:23', () => {
const date = '2021-01-02T01:23'
const d = date.match(REGEX_PARSE)
expect(dayjs(date).valueOf()).toBe(moment(date).valueOf())
expect(d.join('-')).toBe('2021-01-02T01:23-2021-01-02-01-23--')
})
it('2021-01-02T01:23:45', () => {
const date = '2021-01-02T01:23:45'
const d = date.match(REGEX_PARSE)
expect(dayjs(date).valueOf()).toBe(moment(date).valueOf())
expect(d.join('-')).toBe('2021-01-02T01:23:45-2021-01-02-01-23-45-')
})
it('2021-01-02T01:23:45-0500 (no regex match)', () => {
const date = '2021-01-02T01:23:45-0500'
const d = date.match(REGEX_PARSE)
expect(dayjs(date).valueOf()).toBe(moment(date).valueOf())
expect(d).toBe(null)
})
it('2021-01-02T01:23:45Z (no regex match)', () => {
const date = '2021-01-02T01:23:45Z'
const d = date.match(REGEX_PARSE)
expect(dayjs(date).valueOf()).toBe(moment(date).valueOf())
expect(d).toBe(null)
})
})

0 comments on commit cfcf088

Please sign in to comment.