summaryrefslogtreecommitdiff
path: root/spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js
blob: 47bb512cbb5c64fdc3eda6e29ef9f614e757fd7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { newDateAsLocaleTime } from '~/lib/utils/datetime/date_calculation_utility';

describe('newDateAsLocaleTime', () => {
  it.each`
    string                        | expected
    ${'2022-03-22'}               | ${new Date('2022-03-22T00:00:00.000Z')}
    ${'2022-03-22T00:00:00.000Z'} | ${new Date('2022-03-22T00:00:00.000Z')}
    ${2022}                       | ${null}
    ${[]}                         | ${null}
    ${{}}                         | ${null}
    ${true}                       | ${null}
    ${null}                       | ${null}
    ${undefined}                  | ${null}
  `('returns $expected given $string', ({ string, expected }) => {
    expect(newDateAsLocaleTime(string)).toEqual(expected);
  });
});