test(input): test that input[email"] and ngRequired don't interfere w/ eachother

ngRequired added to an email field wasn't working properly. ng-invalid-required
stayed true unless a valid email was entered.

correct behaviour is that it turns to ng-valid-required at first entered key.

Closes #7849
This commit is contained in:
Christophe Krebser
2014-06-17 14:49:53 +02:00
committed by Igor Minar
parent 6737924210
commit deb008d638

View File

@@ -486,6 +486,7 @@ describe('ngModel', function() {
expect(element).toHaveClass('ng-invalid-required');
}));
it('should set the control touched state on "blur" event', inject(function($compile, $rootScope) {
var element = $compile('<form name="myForm">' +
'<input name="myControl" ng-model="value" >' +
@@ -2718,6 +2719,16 @@ describe('input', function() {
});
it('should set $valid even if model fails other validators', function() {
compileInput('<input type="email" ng-model="value" required />');
changeInputValueTo('bademail');
expect(inputElm).toHaveClass('ng-valid-required');
expect(inputElm.controller('ngModel').$error.required).toBe(false);
expect(inputElm).toBeInvalid(); // invalid because of the email validator
});
it('should allow `false` as a valid value when the input type is not "checkbox"', function() {
compileInput('<input type="radio" ng-value="true" ng-model="answer" required />' +
'<input type="radio" ng-value="false" ng-model="answer" required />');