From fd21c7502f0a25364a810c26ebeecb678e5783c5 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 2 May 2013 10:47:30 -0400 Subject: fix(ngAnamite): eval ng-animate expression on each animation --- test/ng/animatorSpec.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/ng/animatorSpec.js b/test/ng/animatorSpec.js index 1b393e91..daab9721 100644 --- a/test/ng/animatorSpec.js +++ b/test/ng/animatorSpec.js @@ -336,10 +336,29 @@ describe("$animator", function() { })); }); - it("should throw an error when an invalid ng-animate syntax is provided", inject(function($compile, $rootScope) { + describe('anmation evaluation', function () { + it('should re-evaluate the animation expression on each animation', inject(function($animator, $rootScope) { + var parent = jqLite('
'); + var element = parent.find('span'); + + $rootScope.animationFn = function () { throw new Error('too early'); }; + var animate = $animator($rootScope, { ngAnimate: 'animationFn()' }); + var log = ''; + + $rootScope.animationFn = function () { log = 'abc' }; + animate.enter(element, parent); + expect(log).toEqual('abc'); + + $rootScope.animationFn = function () { log = 'xyz' }; + animate.enter(element, parent); + expect(log).toEqual('xyz'); + })); + }); + + it("should throw an error when an invalid ng-animate syntax is provided", inject(function($animator, $rootScope) { expect(function() { - element = $compile('
')($rootScope); - $rootScope.$digest(); + var animate = $animator($rootScope, { ngAnimate: ':' }); + animate.enter(); }).toThrow("Syntax Error: Token ':' not a primary expression at column 1 of the expression [:] starting at [:]."); })); }); -- cgit v1.2.3