diff options
| author | Matias Niemelä | 2014-01-11 23:44:43 -0500 | 
|---|---|---|
| committer | Matias Niemelä | 2014-01-14 13:20:50 -0500 | 
| commit | ed53100a0dbc9119d5dfc8b7248845d4f6989df2 (patch) | |
| tree | e2190d53e3489259bfba4d4a67355745e1a75d3f /test | |
| parent | 6df598d9f5a52085b90085b41631ef34f3edc386 (diff) | |
| download | angular.js-ed53100a0dbc9119d5dfc8b7248845d4f6989df2.tar.bz2 | |
fix($animate): ensure the final closing timeout respects staggering animations
Diffstat (limited to 'test')
| -rw-r--r-- | test/ngAnimate/animateSpec.js | 44 | 
1 files changed, 43 insertions, 1 deletions
| diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 2a83f2d5..1bb818af 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1155,7 +1155,7 @@ describe("ngAnimate", function() {            })); -          it("apply a closing timeout to close all pending transitions", +          it("should apply a closing timeout to close all pending transitions",              inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {              if (!$sniffer.transitions) return; @@ -1174,6 +1174,48 @@ describe("ngAnimate", function() {              expect(element.hasClass('some-class-add-active')).toBe(false);            })); +          it("apply a closing timeout with respect to a staggering animation", +            inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { + +            if (!$sniffer.transitions) return; + +            ss.addRule('.entering-element.ng-enter', +              '-webkit-transition:5s linear all;' + +                      'transition:5s linear all;'); + +            ss.addRule('.entering-element.ng-enter-stagger', +              '-webkit-transition-delay:0.5s;' + +                      'transition-delay:0.5s;'); + +            element = $compile(html('<div></div>'))($rootScope); +            var kids = []; +            for(var i = 0; i < 5; i++) { +              kids.push(angular.element('<div class="entering-element"></div>')); +              $animate.enter(kids[i], element); +            } +            $rootScope.$digest(); + +            $timeout.flush(10); //reflow +            expect(element.children().length).toBe(5); + +            for(var i = 0; i < 5; i++) { +              expect(kids[i].hasClass('ng-enter-active')).toBe(true); +            } + +            $timeout.flush(7500); + +            for(var i = 0; i < 5; i++) { +              expect(kids[i].hasClass('ng-enter-active')).toBe(true); +            } + +            //(stagger * index) + (duration + delay) * 150% +            $timeout.flush(9500); //0.5 * 4 + 5 * 1.5 = 9500; + +            for(var i = 0; i < 5; i++) { +              expect(kids[i].hasClass('ng-enter-active')).toBe(false); +            } +          })); +            it("should not allow the closing animation to close off a successive animation midway",              inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { | 
