[ADF-2925] Required and invalid validators added (#3277)

* test added

* tests clean

* test added

* tslint clean

* test name changed

* update tests
This commit is contained in:
bbcodrin
2018-05-15 15:21:38 +03:00
committed by Maurizio Vitale
parent db7d0b7c08
commit fd924c439a
3 changed files with 33 additions and 4 deletions

View File

@@ -136,4 +136,28 @@ describe('SearchNumberRangeComponent', () => {
expect(component.formValidator).toBeTruthy();
});
it('should throw pattern error if "from" value is formed by letters', () => {
component.ngOnInit();
component.from = new FormControl('abc', component.validators);
expect(component.from.hasError('pattern')).toBe(true);
});
it('should not throw pattern error if "from" value is formed by digits', () => {
component.ngOnInit();
component.from = new FormControl(123, component.validators);
expect(component.from.hasError('pattern')).toBe(false);
});
it('should throw required error if "from" value is empty', () => {
component.ngOnInit();
component.from = new FormControl('', component.validators);
expect(component.from.hasError('required')).toBe(true);
});
it('should not throw required error if "from" value is not empty', () => {
component.ngOnInit();
component.from = new FormControl(123, component.validators);
expect(component.from.hasError('required')).toBe(false);
});
});