mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
Fixed negation grouping bug
Make 'this' of validation be scope
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
ValidatorTest = TestCase('ValidatorTest');
|
||||
|
||||
ValidatorTest.prototype.testItShouldHaveThisSet = function() {
|
||||
expectAsserts(5);
|
||||
var self;
|
||||
angular.validator.myValidator = function(first, last){
|
||||
assertEquals('misko', first);
|
||||
assertEquals('hevery', last);
|
||||
self = this;
|
||||
};
|
||||
var c = compile('<input name="name" ng-validate="myValidator:\'hevery\'"/>');
|
||||
c.scope.set('name', 'misko');
|
||||
c.scope.set('state', 'abc');
|
||||
c.binder.updateView();
|
||||
assertEquals('abc', self.state);
|
||||
assertEquals('misko', self.name);
|
||||
assertEquals('name', self.$element.name);
|
||||
};
|
||||
|
||||
ValidatorTest.prototype.testRegexp = function() {
|
||||
assertEquals(angular.validator.regexp("abc", /x/, "E1"), "E1");
|
||||
assertEquals(angular.validator.regexp("abc", '/x/'),
|
||||
@@ -64,4 +81,3 @@ ValidatorTest.prototype.testJson = function() {
|
||||
assertNotNull(angular.validator.json("''X"));
|
||||
assertNull(angular.validator.json("{}"));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user