Commit 92aa80b9 authored by Tim Zallmann's avatar Tim Zallmann

Updated checking if a date is invalid

As no error is thrown anymore in dateformat

Removed test setup
parent 836014cf
......@@ -26,14 +26,7 @@ const isValidDateString = (dateString) => {
return false;
}
try {
// dateformat throws error that can be caught.
// This is better than using `new Date()`
dateformat(dateString, 'isoUtcDateTime');
return true;
} catch (e) {
return false;
}
return !Number.isNaN(Date.parse(dateformat(dateString, 'isoUtcDateTime')));
};
const handleRangeDirection = ({ direction = DEFAULT_DIRECTION, anchorDate, minDate, maxDate }) => {
......
......@@ -14,7 +14,7 @@ describe('spec/helpers/fake_date', () => {
it('should use default args when called as a function', () => {
expect(FakeDate()).toMatchInlineSnapshot(
`"Mon Jul 06 2020 00:00:00 UTC (Greenwich Mean Time)"`,
`"Mon Jul 06 2020 00:00:00 GMT+0000 (Greenwich Mean Time)"`,
);
});
......
......@@ -313,10 +313,10 @@ describe('tags list row', () => {
});
describe.each`
name | finderFunction | text | icon | clipboard
name | finderFunction | text | icon | clipboard
${'published date detail'} | ${findPublishedDateDetail} | ${'Published to the gitlab-org/gitlab-test/rails-12009 image repository at 01:29 UTC on 2020-11-03'} | ${'clock'} | ${false}
${'manifest detail'} | ${findManifestDetail} | ${'Manifest digest: sha256:2cf3d2fdac1b04a14301d47d51cb88dcd26714c74f91440eeee99ce399089062'} | ${'log'} | ${true}
${'configuration detail'} | ${findConfigurationDetail} | ${'Configuration digest: sha256:c2613843ab33aabf847965442b13a8b55a56ae28837ce182627c0716eb08c02b'} | ${'cloud-gear'} | ${true}
${'manifest detail'} | ${findManifestDetail} | ${'Manifest digest: sha256:2cf3d2fdac1b04a14301d47d51cb88dcd26714c74f91440eeee99ce399089062'} | ${'log'} | ${true}
${'configuration detail'} | ${findConfigurationDetail} | ${'Configuration digest: sha256:c2613843ab33aabf847965442b13a8b55a56ae28837ce182627c0716eb08c02b'} | ${'cloud-gear'} | ${true}
`('$name details row', ({ finderFunction, text, icon, clipboard }) => {
it(`has ${text} as text`, async () => {
mountComponent();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment