diff --git a/npm/ng-packs/packages/core/src/lib/tests/validators.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/validators.spec.ts index 6bc33dbfda..695625b740 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/validators.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/validators.spec.ts @@ -5,6 +5,7 @@ import { validateCreditCard } from '../validators/credit-card.validator'; import { validateRequired } from '../validators/required.validator'; import { validateStringLength } from '../validators/string-length.validator'; import { validateUrl } from '../validators/url.validator'; +import { validateUniqueCharacter } from '../validators'; const emailAddress = () => Validators.email; @@ -181,4 +182,25 @@ describe('Validators', () => { expect(control.errors).toEqual(expected); }); }); + + describe('Unique Character Validator', () => { + const error = { uniqueCharacter: true }; + + test.each` + input | expected + ${undefined} | ${null} + ${null} | ${null} + ${''} | ${null} + ${'password'} | ${error} + ${'123456789'} | ${null} + ${'1q2w3E*'} | ${null} + ${'password123'} | ${error} + `('should return $expected when input is $input', ({ input, expected }) => { + const control = new FormControl(input, [validateUniqueCharacter()]); + control.markAsDirty({ onlySelf: true }); + control.updateValueAndValidity({ onlySelf: true, emitEvent: false }); + + expect(control.errors).toEqual(expected); + }); + }); });