validation Presence() unit tests for ng-invalid class
This commit is contained in:
parent
8c6131322f
commit
12b3342953
|
@ -55,10 +55,7 @@ describe('Directive validation', () => {
|
||||||
let html = `<form><input type="name" ng-model="user.name" vn-validation="user.name"/></form>`;
|
let html = `<form><input type="name" ng-model="user.name" vn-validation="user.name"/></form>`;
|
||||||
let validations = {User: {validations: {name: [{validation: 'presence'}]}}};
|
let validations = {User: {validations: {name: [{validation: 'presence'}]}}};
|
||||||
compile(html, validations, 'spiderman');
|
compile(html, validations, 'spiderman');
|
||||||
scope.user.email = '1234?';
|
scope.user.name = '';
|
||||||
|
|
||||||
expect(element[0].classList).toContain('ng-valid');
|
|
||||||
expect(element[0].classList).not.toContain('ng-invalid');
|
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
|
|
||||||
expect(element[0].classList).toContain('ng-invalid');
|
expect(element[0].classList).toContain('ng-invalid');
|
||||||
|
@ -70,9 +67,6 @@ describe('Directive validation', () => {
|
||||||
let validations = {User: {validations: {email: [{validation: 'presence'}]}}};
|
let validations = {User: {validations: {email: [{validation: 'presence'}]}}};
|
||||||
compile(html, validations, 'user@verdnatura.es');
|
compile(html, validations, 'user@verdnatura.es');
|
||||||
scope.user.email = 'user@verdnatura.es';
|
scope.user.email = 'user@verdnatura.es';
|
||||||
|
|
||||||
expect(element[0].classList).toContain('ng-valid');
|
|
||||||
expect(element[0].classList).not.toContain('ng-invalid');
|
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
|
|
||||||
expect(element[0].classList).toContain('ng-valid');
|
expect(element[0].classList).toContain('ng-valid');
|
||||||
|
|
Loading…
Reference in New Issue