diff options
| author | Matias Niemelä | 2014-01-13 21:51:08 -0500 |
|---|---|---|
| committer | Matias Niemelä | 2014-01-14 13:21:28 -0500 |
| commit | dde1b2949727c297e214c99960141bfad438d7a4 (patch) | |
| tree | a433c7813bacdf98fa04f075becec0604b0b155c /test/ngAnimate/animateSpec.js | |
| parent | 4ae3184c5915aac9aa00889aa2153c8e84c14966 (diff) | |
| download | angular.js-dde1b2949727c297e214c99960141bfad438d7a4.tar.bz2 | |
feat($animate): provide support for DOM callbacks
Diffstat (limited to 'test/ngAnimate/animateSpec.js')
| -rw-r--r-- | test/ngAnimate/animateSpec.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 1477bca0..6d9367bd 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1496,6 +1496,68 @@ describe("ngAnimate", function() { expect(signature).toBe('AB'); })); + it('should fire DOM callbacks on the element being animated', + inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { + + if(!$sniffer.transitions) return; + + $animate.enabled(true); + + ss.addRule('.klass-add', '-webkit-transition:1s linear all;' + + 'transition:1s linear all;'); + + var element = jqLite('<div></div>'); + $rootElement.append(element); + body.append($rootElement); + + var steps = []; + element.on('$animate:before', function(e, data) { + steps.push(['before', data.className, data.event]); + }); + + element.on('$animate:after', function(e, data) { + steps.push(['after', data.className, data.event]); + }); + + $animate.addClass(element, 'klass'); + + $timeout.flush(1); + + expect(steps.pop()).toEqual(['before', 'klass', 'addClass']); + + $animate.triggerReflow(); + $timeout.flush(1); + + expect(steps.pop()).toEqual(['after', 'klass', 'addClass']); + })); + + it('should fire the DOM callbacks even if no animation is rendered', + inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { + + $animate.enabled(true); + + var parent = jqLite('<div></div>'); + var element = jqLite('<div></div>'); + $rootElement.append(parent); + body.append($rootElement); + + var steps = []; + element.on('$animate:before', function(e, data) { + steps.push(['before', data.className, data.event]); + }); + + element.on('$animate:after', function(e, data) { + steps.push(['after', data.className, data.event]); + }); + + $animate.enter(element, parent); + $rootScope.$digest(); + + $timeout.flush(1); + + expect(steps.shift()).toEqual(['before', 'ng-enter', 'enter']); + expect(steps.shift()).toEqual(['after', 'ng-enter', 'enter']); + })); it("should fire a done callback when provided with no animation", inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { |
