From 2e33e89a77d115ff17f5841ec328b1c1e4228161 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sun, 30 May 2010 19:42:21 -0700 Subject: added compiled getterFN for better performance --- test/ScopeSpec.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test') diff --git a/test/ScopeSpec.js b/test/ScopeSpec.js index a3b6d9ae..d93400e5 100644 --- a/test/ScopeSpec.js +++ b/test/ScopeSpec.js @@ -157,4 +157,25 @@ describe('scope/model', function(){ } }); }); + + describe('getterFn', function(){ + it('should get chain', function(){ + expect(getterFn('a.b')(undefined)).toEqual(undefined); + expect(getterFn('a.b')({})).toEqual(undefined); + expect(getterFn('a.b')({a:null})).toEqual(undefined); + expect(getterFn('a.b')({a:{}})).toEqual(undefined); + expect(getterFn('a.b')({a:{b:null}})).toEqual(null); + expect(getterFn('a.b')({a:{b:0}})).toEqual(0); + expect(getterFn('a.b')({a:{b:'abc'}})).toEqual('abc'); + }); + + it('should map type method on top of expression', function(){ + expect(getterFn('a.$filter')({a:[]})('')).toEqual([]); + }); + + it('should bind function this', function(){ + expect(getterFn('a')({a:function($){return this.b + $;}, b:1})(2)).toEqual(3); + + }); + }); }); -- cgit v1.2.3