diff --git a/modules/@angular/forms/test/validators_spec.ts b/modules/@angular/forms/test/validators_spec.ts index d3b290c5e3..83bc9802ba 100644 --- a/modules/@angular/forms/test/validators_spec.ts +++ b/modules/@angular/forms/test/validators_spec.ts @@ -43,6 +43,10 @@ export function main() { it('should error on null', () => { expect(Validators.required(new FormControl(null))).toEqual({'required': true}); }); + it('should not error on undefined', () => { + expect(Validators.required(new FormControl(undefined))).toEqual({'required': true}); + }); + it('should not error on a non-empty string', () => { expect(Validators.required(new FormControl('not empty'))).toBeNull(); }); @@ -72,7 +76,7 @@ export function main() { () => { expect(Validators.minLength(2)(new FormControl(null))).toBeNull(); }); it('should not error on undefined', - () => { expect(Validators.minLength(2)(new FormControl(null))).toBeNull(); }); + () => { expect(Validators.minLength(2)(new FormControl(undefined))).toBeNull(); }); it('should not error on valid strings', () => { expect(Validators.minLength(2)(new FormControl('aa'))).toBeNull(); }); @@ -103,6 +107,9 @@ export function main() { it('should not error on null', () => { expect(Validators.maxLength(2)(new FormControl(null))).toBeNull(); }); + it('should not error on undefined', + () => { expect(Validators.maxLength(2)(new FormControl(undefined))).toBeNull(); }); + it('should not error on valid strings', () => { expect(Validators.maxLength(2)(new FormControl('aa'))).toBeNull(); }); @@ -132,8 +139,9 @@ export function main() { it('should not error on null', () => { expect(Validators.pattern('[a-zA-Z ]+')(new FormControl(null))).toBeNull(); }); - it('should not error on undefined', - () => { expect(Validators.pattern('[a-zA-Z ]+')(new FormControl(null))).toBeNull(); }); + it('should not error on undefined', () => { + expect(Validators.pattern('[a-zA-Z ]+')(new FormControl(undefined))).toBeNull(); + }); it('should not error on null value and "null" pattern', () => { expect(Validators.pattern('null')(new FormControl(null))).toBeNull(); });