test(forms): test undefined as argument to forms (#13720)

PR Close #13720
This commit is contained in:
Mathou54
2016-12-30 13:28:38 +01:00
committed by Igor Minar
parent 1c112ae66e
commit c716532ff2

View File

@ -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(); });