mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 11:37:38 +08:00
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:
committed by
Igor Minar
parent
6737924210
commit
deb008d638
@@ -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 />');
|
||||
|
||||
Reference in New Issue
Block a user