diff options
| author | Matias Niemelä | 2013-12-16 15:45:57 -0500 |
|---|---|---|
| committer | Matias Niemelä | 2013-12-19 16:37:29 -0500 |
| commit | cef084ade9072090259d8c679751cac3ffeaed51 (patch) | |
| tree | fe42b514dbbbdd893122fa3f7c7d647afba676b7 /test | |
| parent | 937caab6475e53a7ea0206e992f8a52449232e78 (diff) | |
| download | angular.js-cef084ade9072090259d8c679751cac3ffeaed51.tar.bz2 | |
feat(ngAnimate): provide configuration support to match specific className values to trigger animations
Closes #5357
Closes #5283
Diffstat (limited to 'test')
| -rw-r--r-- | test/ngAnimate/animateSpec.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index c9a08fe8..fedea535 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -2947,5 +2947,55 @@ describe("ngAnimate", function() { expect(capturedAnimation).toBe('leave'); }); }); + + it('should animate only the specified CSS className', function() { + var captures = {}; + module(function($animateProvider) { + $animateProvider.classNameFilter(/prefixed-animation/); + $animateProvider.register('.capture', function() { + return { + enter : buildFn('enter'), + leave : buildFn('leave') + }; + + function buildFn(key) { + return function(element, className, done) { + captures[key] = true; + (done || className)(); + } + } + }); + }); + inject(function($rootScope, $compile, $rootElement, $document, $timeout, $templateCache, $sniffer, $animate) { + if(!$sniffer.transitions) return; + + var element = $compile('<div class="capture"></div>')($rootScope); + $rootElement.append(element); + jqLite($document[0].body).append($rootElement); + + var enterDone = false; + $animate.enter(element, $rootElement, null, function() { + enterDone = true; + }); + + $rootScope.$digest(); + $timeout.flush(); + + expect(captures['enter']).toBeUndefined(); + expect(enterDone).toBe(true); + + element.addClass('prefixed-animation'); + + var leaveDone = false; + $animate.leave(element, function() { + leaveDone = true; + }); + $rootScope.$digest(); + $timeout.flush(); + + expect(captures['leave']).toBe(true); + expect(leaveDone).toBe(true); + }); + }); }); }); |
