UNPKG

@cnamts/vue-dot

Version:

Implementation of our Design System for the French Health Insurance

36 lines (27 loc) 911 B
import { required, requiredFn } from '../'; describe('required', () => { it('returns an error when the value is falsy', () => { expect(typeof required('')).toBe('string'); }); it('returns an error when the value is an empty array', () => { expect(typeof required([])).toBe('string'); }); it('returns an error when the value is filled with spaces', () => { expect(typeof required(' ')).toBe('string'); }); it('returns an error when the value is null', () => { expect(typeof required(null)).toBe('string'); }); it('returns true when the value is filled with a string', () => { expect(required('test')).toBe(true); }); it('returns true when the value is filled with an array of string', () => { expect(required(['test'])).toBe(true); }); it('works with custom error messages', () => { const rule = requiredFn({ default: 'test' }); expect(rule('')).toBe('test'); }); });