summaryrefslogtreecommitdiff
path: root/spec/frontend/lib/utils/datetime_utility_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/lib/utils/datetime_utility_spec.js')
-rw-r--r--spec/frontend/lib/utils/datetime_utility_spec.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/datetime_utility_spec.js b/spec/frontend/lib/utils/datetime_utility_spec.js
index 27b88d78ff0..f6878c7c920 100644
--- a/spec/frontend/lib/utils/datetime_utility_spec.js
+++ b/spec/frontend/lib/utils/datetime_utility_spec.js
@@ -474,6 +474,23 @@ describe('getDateInFuture', () => {
});
});
+describe('isValidDate', () => {
+ it.each`
+ valueToCheck | isValid
+ ${new Date()} | ${true}
+ ${new Date('December 17, 1995 03:24:00')} | ${true}
+ ${new Date('1995-12-17T03:24:00')} | ${true}
+ ${new Date('foo')} | ${false}
+ ${5} | ${false}
+ ${''} | ${false}
+ ${false} | ${false}
+ ${undefined} | ${false}
+ ${null} | ${false}
+ `('returns $expectedReturnValue when called with $dateToCheck', ({ valueToCheck, isValid }) => {
+ expect(datetimeUtility.isValidDate(valueToCheck)).toBe(isValid);
+ });
+});
+
describe('getDatesInRange', () => {
it('returns an empty array if 1st or 2nd argument is not a Date object', () => {
const d1 = new Date('2019-01-01');