@cnamts/vue-dot
Version:
Implementation of our Design System for the French Health Insurance
27 lines (20 loc) • 625 B
text/typescript
import { isDateValid, isDateValidFn } from '../';
const validDate = '14/09/2019';
const invalidDate = '99/99/9999';
describe('isDateValid', () => {
it('returns an error when the date is not valid', () => {
expect(typeof isDateValid(invalidDate)).toBe('string');
});
it('returns true when the date is valid', () => {
expect(isDateValid(validDate)).toBe(true);
});
it('returns true if the value is falsy', () => {
expect(isDateValid('')).toBe(true);
});
it('works with custom error messages', () => {
const rule = isDateValidFn({
default: 'test'
});
expect(rule(invalidDate)).toBe('test');
});
});