aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngAnimate
diff options
context:
space:
mode:
authorMatias Niemelä2013-10-22 01:53:40 -0400
committerMatias Niemelä2013-10-23 07:26:41 -0400
commit2623de1426219dc799f63a3d155911f93fc03461 (patch)
treec08a9aa9b6b88d1a22a7bfd3e001c9f701e3ace8 /test/ngAnimate
parentf5289fe84ffc1f2368dae7bd14c420abbe76749e (diff)
downloadangular.js-2623de1426219dc799f63a3d155911f93fc03461.tar.bz2
fix($animate): ensure animations work properly when the $rootElement is being animated
Closes #4397 Closes #4231
Diffstat (limited to 'test/ngAnimate')
-rw-r--r--test/ngAnimate/animateSpec.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js
index 6dfd46e5..3919dc53 100644
--- a/test/ngAnimate/animateSpec.js
+++ b/test/ngAnimate/animateSpec.js
@@ -56,6 +56,70 @@ describe("ngAnimate", function() {
expect($animate.enabled(1)).toBe(true);
expect($animate.enabled()).toBe(true);
});
+
+ it('should place a hard disable on all child animations', function() {
+ var count = 0;
+ module(function($animateProvider) {
+ $animateProvider.register('.animated', function() {
+ return {
+ addClass : function(element, className, done) {
+ count++;
+ done();
+ }
+ }
+ });
+ });
+ inject(function($compile, $rootScope, $animate, $sniffer, $rootElement, $timeout) {
+ $animate.enabled(true);
+
+ var elm1 = $compile('<div class="animated"></div>')($rootScope);
+ var elm2 = $compile('<div class="animated"></div>')($rootScope);
+ $rootElement.append(elm1);
+ angular.element(document.body).append($rootElement);
+
+ $animate.addClass(elm1, 'klass');
+ expect(count).toBe(1);
+
+ $animate.enabled(false);
+
+ $animate.addClass(elm1, 'klass2');
+ expect(count).toBe(1);
+
+ $animate.enabled(true);
+
+ elm1.append(elm2);
+
+ $animate.addClass(elm2, 'klass');
+ expect(count).toBe(2);
+
+ $animate.enabled(false, elm1);
+
+ $animate.addClass(elm2, 'klass2');
+ expect(count).toBe(2);
+ });
+ });
+
+ it('should skip animations if the element is attached to the $rootElement', function() {
+ var count = 0;
+ module(function($animateProvider) {
+ $animateProvider.register('.animated', function() {
+ return {
+ addClass : function(element, className, done) {
+ count++;
+ done();
+ }
+ }
+ });
+ });
+ inject(function($compile, $rootScope, $animate, $sniffer, $rootElement, $timeout) {
+ $animate.enabled(true);
+
+ var elm1 = $compile('<div class="animated"></div>')($rootScope);
+
+ $animate.addClass(elm1, 'klass2');
+ expect(count).toBe(0);
+ });
+ });
});
describe("with polyfill", function() {
@@ -1956,4 +2020,28 @@ describe("ngAnimate", function() {
expect(element.hasClass('red-add')).toBe(false);
expect(element.hasClass('yellow-add')).toBe(true);
}));
+
+ it('should enable and disable animations properly on the root element', function() {
+ var count = 0;
+ module(function($animateProvider) {
+ $animateProvider.register('.animated', function() {
+ return {
+ addClass : function(element, className, done) {
+ count++;
+ done();
+ }
+ }
+ });
+ });
+ inject(function($compile, $rootScope, $animate, $sniffer, $rootElement, $timeout) {
+
+ $rootElement.addClass('animated');
+ $animate.addClass($rootElement, 'green');
+ expect(count).toBe(1);
+
+ $animate.addClass($rootElement, 'red');
+ expect(count).toBe(2);
+ });
+ });
+
});