From 2430347ece2f7a74a35d3ab0095ecc895884670e Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Tue, 6 Aug 2013 14:15:01 -0400 Subject: fix(ngAnimate): make sure that the class value passed into addClass/removeClass is the base class string value --- test/ngAnimate/animateSpec.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test') diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index e5ade9f3..30bf6ba7 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1513,4 +1513,36 @@ describe("ngAnimate", function() { }); }); + it("should provide the correct CSS class to the addClass and removeClass callbacks within a JS animation", function() { + module(function($animateProvider) { + $animateProvider.register('.classify', function($timeout) { + return { + removeClass : function(element, className, done) { + element.data('classify','remove-' + className); + done(); + }, + addClass : function(element, className, done) { + element.data('classify','add-' + className); + done(); + } + } + }); + }) + inject(function($compile, $rootScope, $animate, $timeout) { + var element = html($compile('
')($rootScope)); + + $animate.addClass(element, 'super'); + expect(element.data('classify')).toBe('add-super'); + $timeout.flush(); + + $animate.removeClass(element, 'super'); + expect(element.data('classify')).toBe('remove-super'); + $timeout.flush(); + + $animate.addClass(element, 'superguy'); + expect(element.data('classify')).toBe('add-superguy'); + $timeout.flush(); + }); + }); + }); -- cgit v1.2.3