aboutsummaryrefslogtreecommitdiffstats
path: root/test/ScopeSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/ScopeSpec.js')
-rw-r--r--test/ScopeSpec.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/test/ScopeSpec.js b/test/ScopeSpec.js
index d93400e5..ea63fea4 100644
--- a/test/ScopeSpec.js
+++ b/test/ScopeSpec.js
@@ -15,28 +15,42 @@ describe('scope/model', function(){
expect(model.$root).toEqual(model);
});
+ it('should return noop function when LHS is undefined', function(){
+ var model = createScope();
+ expect(model.$eval('x.$filter()')).toEqual(undefined);
+ });
+
describe('$eval', function(){
- it('should eval function with correct this and pass arguments', function(){
- var model = createScope();
- model.$eval(function(name){
- this.name = name;
- }, 'works');
+ var model;
+
+ beforeEach(function(){model = createScope();});
+
+ it('should eval function with correct this', function(){
+ model.$eval(function(){
+ this.name = 'works';
+ });
expect(model.name).toEqual('works');
});
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(){