UNPKG

@haravan-tech/util

Version:

utilities

26 lines (20 loc) 669 B
'use strict'; const { isValidDate, nowLS, regex, } = require('../'); it ('should return a time string in vi locale', () => { let locale = 'vi-VN'; expect(regex.date.localeString[locale].test(nowLS(locale))).toBeTruthy(); }); it ('should be a valid date', () => { expect(isValidDate(new Date())).toBeTruthy(); expect(isValidDate(new Date().getTime())).toBeTruthy(); expect(isValidDate(new Date().toLocaleString('vi-VN'))).toBeTruthy(); }); it ('should be an invalid date', () => { expect(isValidDate(new Date(''))).toBeFalsy(); expect(isValidDate('2018-20-10')).toBeFalsy(); expect(isValidDate(null)).toBeFalsy(); });