@cnamts/vue-dot
Version:
Implementation of our Design System for the French Health Insurance
25 lines (18 loc) • 643 B
text/typescript
import { notAfterDate } from '../';
import dayjs from 'dayjs';
import { formatDate } from '../../../functions/formatDate';
describe('notAfterDate', () => {
const currentDate = formatDate(dayjs());
const pastDate = formatDate(dayjs().subtract(1, 'year'));
const futureDate = formatDate(dayjs().add(1, 'year'));
const rule = notAfterDate(currentDate);
it('returns true with a past date', () => {
expect(rule(pastDate)).toBe(true);
});
it('returns an error with a future date', () => {
expect(typeof rule(futureDate)).toBe('string');
});
it('returns true if the value is falsy', () => {
expect(rule('')).toBe(true);
});
});