aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatias Niemelä2014-01-02 14:52:49 -0500
committerMatias Niemelä2014-01-14 13:18:50 -0500
commit524650a40ed20f01571e5466475749874ee67288 (patch)
tree04f72623df7c18002fb2ae5021a8a43fc838bd28 /test
parent02a45826f12842a5eec07989264abbe42b381a7c (diff)
downloadangular.js-524650a40ed20f01571e5466475749874ee67288.tar.bz2
fix($animate): avoid accidentally matching substrings when resolving the presence of className tokens
Diffstat (limited to 'test')
-rw-r--r--test/ngAnimate/animateSpec.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js
index 028c021f..db40d544 100644
--- a/test/ngAnimate/animateSpec.js
+++ b/test/ngAnimate/animateSpec.js
@@ -2665,6 +2665,37 @@ describe("ngAnimate", function() {
expect(element.hasClass('red')).toBe(true);
}));
+ it("should avoid mixing up substring classes during add and remove operations", function() {
+ var currentAnimation, currentFn;
+ module(function($animateProvider) {
+ $animateProvider.register('.on', function() {
+ return {
+ beforeAddClass : function(element, className, done) {
+ currentAnimation = 'addClass';
+ currentFn = done;
+ },
+ beforeRemoveClass : function(element, className, done) {
+ currentAnimation = 'removeClass';
+ currentFn = done;
+ }
+ };
+ });
+ });
+ inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
+ var element = $compile('<div class="animation-enabled only"></div>')($rootScope);
+ $rootElement.append(element);
+ jqLite($document[0].body).append($rootElement);
+
+ $animate.addClass(element, 'on');
+ expect(currentAnimation).toBe('addClass');
+ currentFn();
+
+ $animate.removeClass(element, 'on');
+ $animate.addClass(element, 'on');
+
+ expect(currentAnimation).toBe('addClass');
+ });
+ });
it('should enable and disable animations properly on the root element', function() {
var count = 0;