From cfcf088b9520950307bc1edfe044d614e613daa5 Mon Sep 17 00:00:00 2001 From: bcurtin144 <32525780+bcurtin144@users.noreply.github.com> Date: Sat, 2 Jan 2021 02:18:50 -0600 Subject: [PATCH] add tests for REGEX_PARSE includes two tests that would have matched before fix #1239 but no longer match --- test/parse.test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/parse.test.js b/test/parse.test.js index aecbaa898..ba63e044f 100644 --- a/test/parse.test.js +++ b/test/parse.test.js @@ -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) + }) })