diff options
| author | Matias Niemelàˆ | 2013-04-09 18:33:16 -0400 |
|---|---|---|
| committer | Misko Hevery | 2013-04-11 14:15:20 -0700 |
| commit | 1351ba2632b5011ad6eaddf004a7f0411bea8453 (patch) | |
| tree | 2afaf00419536007ee6330a3ff047708e931d5b5 /test/ng/animatorSpec.js | |
| parent | 5476cb6e9b6d7a16e3a86585bc2db5e63b16cd4d (diff) | |
| download | angular.js-1351ba2632b5011ad6eaddf004a7f0411bea8453.tar.bz2 | |
fix(ngAnimate): skip animation on first render
Diffstat (limited to 'test/ng/animatorSpec.js')
| -rw-r--r-- | test/ng/animatorSpec.js | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/test/ng/animatorSpec.js b/test/ng/animatorSpec.js index 79457488..7cf785e0 100644 --- a/test/ng/animatorSpec.js +++ b/test/ng/animatorSpec.js @@ -2,10 +2,21 @@ describe("$animator", function() { - var element; + var body, element; + + function html(html) { + body.html(html); + element = body.children().eq(0); + return element; + } + + beforeEach(function() { + // we need to run animation on attached elements; + body = jqLite(document.body); + }); afterEach(function(){ - dealoc(element); + dealoc(body); }); describe("enable / disable", function() { @@ -120,6 +131,7 @@ describe("$animator", function() { animator = $animator($rootScope, { ngAnimate : '{enter: \'custom\'}' }); + $rootScope.$digest(); // re-enable the animations; expect(element.contents().length).toBe(0); animator.enter(child, element); window.setTimeout.expect(1).process(); @@ -129,6 +141,7 @@ describe("$animator", function() { animator = $animator($rootScope, { ngAnimate : '{leave: \'custom\'}' }); + $rootScope.$digest(); element.append(child); expect(element.contents().length).toBe(1); animator.leave(child, element); @@ -140,6 +153,7 @@ describe("$animator", function() { animator = $animator($rootScope, { ngAnimate : '{move: \'custom\'}' }); + $rootScope.$digest(); var child1 = $compile('<div>1</div>')($rootScope); var child2 = $compile('<div>2</div>')($rootScope); element.append(child1); @@ -154,6 +168,7 @@ describe("$animator", function() { animator = $animator($rootScope, { ngAnimate : '{show: \'custom\'}' }); + $rootScope.$digest(); element.css('display','none'); expect(element.css('display')).toBe('none'); animator.show(element); @@ -166,6 +181,7 @@ describe("$animator", function() { animator = $animator($rootScope, { ngAnimate : '{hide: \'custom\'}' }); + $rootScope.$digest(); element.css('display','block'); expect(element.css('display')).toBe('block'); animator.hide(element); @@ -181,6 +197,8 @@ describe("$animator", function() { ngAnimate : '"custom"' }); + $rootScope.$digest(); + //enter animator.enter(child, element); expect(child.attr('class')).toContain('custom-enter-setup'); @@ -222,6 +240,7 @@ describe("$animator", function() { animator = $animator($rootScope, { ngAnimate : '{show: \'setup-memo\'}' }); + $rootScope.$digest(); expect(element.text()).toEqual(''); animator.show(element); window.setTimeout.expect(1).process(); @@ -234,6 +253,8 @@ describe("$animator", function() { animator = $animator($rootScope, { ngAnimate : '{show: \'setup-memo\'}' }); + $rootScope.$digest(); + element.text('123'); expect(element.text()).toBe('123'); animator.show(element); @@ -262,11 +283,13 @@ describe("$animator", function() { it("should skip animations if disabled and run when enabled", inject(function($animator, $rootScope, $compile, $sniffer) { $animator.enabled(false); - element = $compile('<div style="transition: 1s linear all">1</div>')($rootScope); + element = $compile(html('<div style="' + vendorPrefix + 'transition: 1s linear all">1</div>'))($rootScope); var animator = $animator($rootScope, { ngAnimate : '{show: \'inline-show\'}' }); + $rootScope.$digest(); // skip no-animate on first digest. + element.css('display','none'); expect(element.css('display')).toBe('none'); animator.show(element); @@ -289,6 +312,7 @@ describe("$animator", function() { it("should throw an error when an invalid ng-animate syntax is provided", inject(function($compile, $rootScope) { expect(function() { element = $compile('<div ng-repeat="i in is" ng-animate=":"></div>')($rootScope); + $rootScope.$digest(); }).toThrow("Syntax Error: Token ':' not a primary expression at column 1 of the expression [:] starting at [:]."); })); }); |
