From cef084ade9072090259d8c679751cac3ffeaed51 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Mon, 16 Dec 2013 15:45:57 -0500 Subject: feat(ngAnimate): provide configuration support to match specific className values to trigger animations Closes #5357 Closes #5283 --- test/ngAnimate/animateSpec.js | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'test/ngAnimate/animateSpec.js') 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('
')($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); + }); + }); }); }); -- cgit v1.2.3