diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/FiltersTest.js | 8 | ||||
| -rw-r--r-- | test/ParserTest.js | 10 | ||||
| -rw-r--r-- | test/ScopeTest.js | 3 | ||||
| -rw-r--r-- | test/ValidatorsTest.js | 18 |
4 files changed, 33 insertions, 6 deletions
diff --git a/test/FiltersTest.js b/test/FiltersTest.js index 5ca63ca7..e6e8b662 100644 --- a/test/FiltersTest.js +++ b/test/FiltersTest.js @@ -2,7 +2,7 @@ FiltersTest = TestCase('FiltersTest'); FiltersTest.prototype.testCurrency = function(){ var html = $('<span/>'); - var context = {element:html[0]}; + var context = {$element:html[0]}; var currency = bind(context, angular.filter.currency); assertEquals(currency(0), '$0.00'); @@ -17,10 +17,10 @@ FiltersTest.prototype.testFilterThisIsContext = function(){ expectAsserts(2); var scope = new Scope(); Scope.expressionCache = {}; - var context = {element:123}; + var context = {$element:123, self:{name:'misko'}}; angular.filter.testFn = function () { - assertEquals('Context not equal', this, context); - assertEquals('scope not equal', this.scope, scope); + assertEquals('Context not equal', 123, this.$element); + assertEquals('scope not equal', 'misko', this.name); }; scope.eval("0|testFn", context); delete angular.filter['testFn']; diff --git a/test/ParserTest.js b/test/ParserTest.js index 2fcbc7fe..09c3b8de 100644 --- a/test/ParserTest.js +++ b/test/ParserTest.js @@ -160,6 +160,9 @@ ParserTest.prototype.testComparison = function(){ assertEquals(scope.eval("1<=1"), true); assertEquals(scope.eval("1>2"), 1>2); assertEquals(scope.eval("2>=1"), 2>=1); + + assertEquals(true==2<3, scope.eval("true==2<3")); + }; ParserTest.prototype.testLogical = function(){ @@ -467,3 +470,10 @@ ParserTest.prototype.testDoubleNegationBug = function (){ assertEquals('a', scope.eval('{true:"a", false:"b"}[!!true]')); }; +ParserTest.prototype.testNegationBug = function () { + var scope = new Scope(); + assertEquals(!false || true, scope.eval("!false || true")); + assertEquals(!11 == 10, scope.eval("!11 == 10")); + assertEquals(12/6/2, scope.eval("12/6/2")); +}; + diff --git a/test/ScopeTest.js b/test/ScopeTest.js index b066f0cb..24febf19 100644 --- a/test/ScopeTest.js +++ b/test/ScopeTest.js @@ -83,8 +83,9 @@ ScopeTest.prototype.testGlobalFunctionAccess =function(){ ScopeTest.prototype.testValidationEval = function(){ expectAsserts(4); var scope = new Scope(); + scope.set("name", "misko"); angular.validator.testValidator = function(value, expect){ - assertEquals(scope, this.scope); + assertEquals("misko", this.name); return value == expect ? null : "Error text"; }; diff --git a/test/ValidatorsTest.js b/test/ValidatorsTest.js index f06e0b3a..a4e603fa 100644 --- a/test/ValidatorsTest.js +++ b/test/ValidatorsTest.js @@ -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("{}")); }; - |
