import { transformStringToDate } from './transformStringToDate'; describe('#stringToDate', () => { test.each([ ['2021-01-30T16:00:00.000Z', '2021-01-30T16:00:00.000Z'], ['2021-01-31T00:00:00', '2021-01-31 00:00:00'], ['2021-01-31 00:00:00', '2021-01-31 00:00:00'], ['01/31/2021', '2021-01-31 00:00:00'], ['01/31/2021 00:00', '2021-01-31 00:00:00'], ['01/31/2021 1:00 am', '2021-01-31 01:00:00'], ['1/31/2021', '2021-01-31 00:00:00'], ['1/31/2021 0:00', '2021-01-31 00:00:00'], ['2021/01/31', '2021-01-31 00:00:00'], ['2021/01/31 00:00', '2021-01-31 00:00:00'], ['2021/01/31 01:00 am', '2021-01-31 01:00:00'], ['2021/1/31', '2021-01-31 00:00:00'], ['2021/1/31 0:00', '2021-01-31 00:00:00'], ['2021-01-31', '2021-01-31 00:00:00'], ['2021-01-31 00:00', '2021-01-31 00:00:00'], ['2021-01-31 01:00 am', '2021-01-31 01:00:00'], ['2021-1-31', '2021-01-31 00:00:00'], ['2021-1-31 0:00', '2021-01-31 00:00:00'], ['2021年1月31日', '2021-01-31 00:00:00'], ['2021年1月31日 0:00', '2021-01-31 00:00:00'], ['2021年1月31日 1:00 am', '2021-01-31 01:00:00'], ['2021年01月31日 00:00', '2021-01-31 00:00:00'], ['Jan 28th, 2021', '2021-01-28 00:00:00'], ['Jan 28th, 2021 00:00', '2021-01-28 00:00:00'], ['Jan 28th, 2021 1:00 am', '2021-01-28 01:00:00'], ['2021年1月', '2021-01-01 00:00:00'], ['2021年', '2021-01-01 00:00:00'], ])('should convert string %p to %p', (input, out) => { expect(transformStringToDate(input)?.getTime()).toEqual(new Date(out).getTime()); }); });