UNPKG

@cnamts/vue-dot

Version:

Implementation of our Design System for the French Health Insurance

31 lines (22 loc) 758 B
import dayjs from 'dayjs'; import { notAfterToday, notAfterTodayFn } from '../'; const DATE_FORMAT = 'DD/MM/YYYY'; const futureDate = dayjs().add(1, 'year').format(DATE_FORMAT); const pastDate = dayjs().subtract(1, 'year').format(DATE_FORMAT); describe('notAfterToday', () => { it('returns an error when the date is future', () => { expect(typeof notAfterToday(futureDate)).toBe('string'); }); it('returns true when the date is past', () => { expect(notAfterToday(pastDate)).toBe(true); }); it('returns true if the value is falsy', () => { expect(notAfterToday('')).toBe(true); }); it('works with custom error messages', () => { const rule = notAfterTodayFn({ default: 'test' }); expect(rule(futureDate)).toBe('test'); }); });