From 9b392eca3597fdc9dab81d88df75bef75f6e678f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 10 Aug 2010 11:23:23 -0700 Subject: fix bug where $eval on undefined throws error --- test/ScopeSpec.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/ScopeSpec.js b/test/ScopeSpec.js index 6f5485e7..ea63fea4 100644 --- a/test/ScopeSpec.js +++ b/test/ScopeSpec.js @@ -21,8 +21,11 @@ describe('scope/model', function(){ }); describe('$eval', function(){ + var model; + + beforeEach(function(){model = createScope();}); + it('should eval function with correct this', function(){ - var model = createScope(); model.$eval(function(){ this.name = 'works'; }); @@ -30,18 +33,24 @@ describe('scope/model', function(){ }); it('should eval expression with correct this', function(){ - var model = createScope(); model.$eval('name="works"'); expect(model.name).toEqual('works'); }); it('should do nothing on empty string and not update view', function(){ - var model = createScope(); var onEval = jasmine.createSpy('onEval'); model.$onEval(onEval); model.$eval(''); expect(onEval).wasNotCalled(); }); + + it('should ignore none string/function', function(){ + model.$eval(null); + model.$eval({}); + model.$tryEval(null); + model.$tryEval({}); + }); + }); describe('$watch', function(){ -- cgit v1.2.3