diff options
Diffstat (limited to 'test/ng/compileSpec.js')
| -rw-r--r-- | test/ng/compileSpec.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 9d0acc22..ae1eb000 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -1857,6 +1857,9 @@ describe('$compile', function() { ref: '=', refAlias: '= ref', reference: '=', + optref: '=?', + optrefAlias: '=? optref', + optreference: '=?', expr: '&', exprAlias: '&expr' }, @@ -1993,6 +1996,33 @@ describe('$compile', function() { }); + describe('optional object reference', function() { + it('should update local when origin changes', inject(function() { + compile('<div><span my-component optref="name">'); + expect(componentScope.optRef).toBe(undefined); + expect(componentScope.optRefAlias).toBe(componentScope.optRef); + + $rootScope.name = 'misko'; + $rootScope.$apply(); + expect(componentScope.optref).toBe($rootScope.name); + expect(componentScope.optrefAlias).toBe($rootScope.name); + + $rootScope.name = {}; + $rootScope.$apply(); + expect(componentScope.optref).toBe($rootScope.name); + expect(componentScope.optrefAlias).toBe($rootScope.name); + })); + + it('should not throw exception when reference does not exist', inject(function() { + compile('<div><span my-component>'); + + expect(componentScope.optref).toBe(undefined); + expect(componentScope.optrefAlias).toBe(undefined); + expect(componentScope.optreference).toBe(undefined); + })); + }); + + describe('executable expression', function() { it('should allow expression execution with locals', inject(function() { compile('<div><span my-component expr="count = count + offset">'); |
