refactor(forms): remove facade (#12558)

This commit is contained in:
Dzmitry Shylovich
2016-11-16 05:48:34 +03:00
committed by Victor Berchet
parent 6a212fd561
commit f79b320fc4
2 changed files with 52 additions and 35 deletions

View File

@ -793,7 +793,7 @@ export function main() {
expect(form.valid).toEqual(true);
}));
it('should support optional fields with pattern validator', fakeAsync(() => {
it('should support optional fields with string pattern validator', fakeAsync(() => {
const fixture = TestBed.createComponent(NgModelMultipleValidators);
fixture.componentInstance.required = false;
fixture.componentInstance.pattern = '[a-z]+';
@ -815,6 +815,28 @@ export function main() {
expect(form.control.hasError('pattern', ['tovalidate'])).toBeTruthy();
}));
it('should support optional fields with RegExp pattern validator', fakeAsync(() => {
const fixture = TestBed.createComponent(NgModelMultipleValidators);
fixture.componentInstance.required = false;
fixture.componentInstance.pattern = /^[a-z]+$/;
fixture.detectChanges();
tick();
const form = fixture.debugElement.children[0].injector.get(NgForm);
const input = fixture.debugElement.query(By.css('input'));
input.nativeElement.value = '';
dispatchEvent(input.nativeElement, 'input');
fixture.detectChanges();
expect(form.valid).toBeTruthy();
input.nativeElement.value = '1';
dispatchEvent(input.nativeElement, 'input');
fixture.detectChanges();
expect(form.valid).toBeFalsy();
expect(form.control.hasError('pattern', ['tovalidate'])).toBeTruthy();
}));
it('should support optional fields with minlength validator', fakeAsync(() => {
const fixture = TestBed.createComponent(NgModelMultipleValidators);
fixture.componentInstance.required = false;
@ -1177,7 +1199,7 @@ class NgModelValidationBindings {
class NgModelMultipleValidators {
required: boolean;
minLen: number;
pattern: string;
pattern: string|RegExp;
}
@Directive({