imput validation is ok with Jest
This commit is contained in:
parent
1e4d432db8
commit
018e17487e
|
@ -7,7 +7,7 @@ describe('Component vnInputNumber', () => {
|
|||
beforeEach(ngModule('vnCore'));
|
||||
|
||||
beforeEach(angular.mock.inject(($compile, $rootScope) => {
|
||||
$element = $compile(`<vn-input-number></vn-input-number>`)($rootScope);
|
||||
$element = $compile(`<vn-input-number ng-model="model" />`)($rootScope);
|
||||
$ctrl = $element.controller('vnInputNumber');
|
||||
}));
|
||||
|
||||
|
@ -20,12 +20,10 @@ describe('Component vnInputNumber', () => {
|
|||
$ctrl.field = -1;
|
||||
$ctrl.min = 0;
|
||||
|
||||
// FIXME: Input validation doesn't work with Jest?
|
||||
// expect($ctrl.shownError).toContain('Please select a value that is no less than 0');
|
||||
expect($ctrl.shownError).toBeNull();
|
||||
expect($ctrl.shownError).toContain('Constraints not satisfied');
|
||||
});
|
||||
|
||||
it(`should unset error property when value is upper than min`, () => {
|
||||
it(`should unset error property when value is greater than min`, () => {
|
||||
$ctrl.field = 1;
|
||||
$ctrl.min = 0;
|
||||
|
||||
|
@ -34,19 +32,16 @@ describe('Component vnInputNumber', () => {
|
|||
});
|
||||
|
||||
describe('max() setter', () => {
|
||||
it(`should set error property when value is upper than max`, () => {
|
||||
it(`should set error property when value is greater than max`, () => {
|
||||
$ctrl.field = 1;
|
||||
$ctrl.max = 0;
|
||||
|
||||
// FIXME: Input validation doesn't work with Jest?
|
||||
// expect($ctrl.shownError).toContain('Please select a value that is no more than 0');
|
||||
expect($ctrl.shownError).toBeNull();
|
||||
expect($ctrl.shownError).toContain('Constraints not satisfied');
|
||||
});
|
||||
|
||||
// FIXME: Input validation doesn't work with Jest?
|
||||
it(`should unset error property when value is lower than max`, () => {
|
||||
$ctrl.field = -1;
|
||||
$ctrl.min = 0;
|
||||
$ctrl.max = 0;
|
||||
|
||||
expect($ctrl.shownError).toBeNull();
|
||||
});
|
||||
|
@ -54,14 +49,12 @@ describe('Component vnInputNumber', () => {
|
|||
|
||||
describe('step() setter', () => {
|
||||
it(`should increase value when add icon is clicked`, () => {
|
||||
$ctrl.step = 1;
|
||||
$ctrl.field = 1;
|
||||
$ctrl.input.step = 1;
|
||||
$ctrl.input.value = 0;
|
||||
|
||||
// FIXME: Doesn't work with Jest?
|
||||
// $ctrl.stepUp();
|
||||
// $element[0].querySelector('vn-icon[icon=add]').click();
|
||||
$ctrl.stepUp();
|
||||
|
||||
expect($ctrl.field).toBe(1);
|
||||
expect($ctrl.input.value).toBe('1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue