mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { UntypedFormBuilder, UntypedFormControl } from '@angular/forms';
|
|
import { fakeAsync, waitForAsync } from '@angular/core/testing';
|
|
import { ConfirmedValidator } from './confirmed.validator';
|
|
|
|
describe('ConfirmedValidator', () => {
|
|
let passwordForm;
|
|
|
|
beforeEach(waitForAsync(() => {
|
|
|
|
passwordForm = (new UntypedFormBuilder()).group({
|
|
password: new UntypedFormControl('', {}),
|
|
confirmPassword: new UntypedFormControl('', {})
|
|
}, {
|
|
validator: ConfirmedValidator('password', 'confirmPassword')
|
|
});
|
|
}));
|
|
|
|
it('should validate that the password and confirm password match', fakeAsync(() => {
|
|
|
|
passwordForm.get('password').patchValue('test-password');
|
|
passwordForm.get('confirmPassword').patchValue('test-password-mismatch');
|
|
|
|
expect(passwordForm.valid).toBe(false);
|
|
}));
|
|
|
|
it('should invalidate that the password and confirm password match', fakeAsync(() => {
|
|
passwordForm.get('password').patchValue('test-password');
|
|
passwordForm.get('confirmPassword').patchValue('test-password');
|
|
|
|
expect(passwordForm.valid).toBe(true);
|
|
}));
|
|
});
|