UNPKG

vue-dotnet-validator

Version:
25 lines (19 loc) 989 B
import StringLengthValidator from './stringlengthvalidator.js'; describe('String length validator', () => { it('Should accept empty values', () => { const validator = new StringLengthValidator('error!', {'valLengthMin': 3, 'valLengthMax': 10}); expect(validator.isValid('')).toBe(true); }); it('Should accept strings with lengths within range', () => { const validator = new StringLengthValidator('error!', {'valLengthMin': 3, 'valLengthMax': 10}); expect(validator.isValid('dag')).toBe(true); expect(validator.isValid('dingen')).toBe(true); expect(validator.isValid('hallo dag!')).toBe(true); }); it('Should reject strings out of the limits of the range', () => { const validator = new StringLengthValidator('error!', {'valLengthMin': 3, 'valLengthMax': 10}); expect(validator.isValid('hi')).toBe(false); expect(validator.isValid('dit is te lang')).toBe(false); expect(validator.isValid('dingen met spullen')).toBe(false); }); });