style(animateSpec): ensure spacing between specs and describes is consistent

This commit is contained in:
Matias Niemelä 2013-12-19 11:56:26 -05:00
parent 54637a335f
commit 3fc8017119

View file

@ -4,6 +4,7 @@ describe("ngAnimate", function() {
beforeEach(module('ngAnimate')); beforeEach(module('ngAnimate'));
it("should disable animations on bootstrap for structural animations even after the first digest has passed", function() { it("should disable animations on bootstrap for structural animations even after the first digest has passed", function() {
var hasBeenAnimated = false; var hasBeenAnimated = false;
module(function($animateProvider) { module(function($animateProvider) {
@ -37,10 +38,12 @@ describe("ngAnimate", function() {
}); });
}); });
//we use another describe block because the before/after operations below //we use another describe block because the before/after operations below
//are used across all animations tests and we don't want that same behavior //are used across all animations tests and we don't want that same behavior
//to be used on the root describe block at the start of the animateSpec.js file //to be used on the root describe block at the start of the animateSpec.js file
describe('', function() { describe('', function() {
var ss, body; var ss, body;
beforeEach(module(function() { beforeEach(module(function() {
body = jqLite(document.body); body = jqLite(document.body);
@ -61,6 +64,7 @@ describe("ngAnimate", function() {
dealoc(body); dealoc(body);
}); });
describe("$animate", function() { describe("$animate", function() {
var element, $rootElement; var element, $rootElement;
@ -85,6 +89,7 @@ describe("ngAnimate", function() {
expect($animate.enabled()).toBe(true); expect($animate.enabled()).toBe(true);
})); }));
it('should place a hard disable on all child animations', function() { it('should place a hard disable on all child animations', function() {
var count = 0; var count = 0;
module(function($animateProvider) { module(function($animateProvider) {
@ -132,6 +137,7 @@ describe("ngAnimate", function() {
}); });
}); });
it('should skip animations if the element is attached to the $rootElement', function() { it('should skip animations if the element is attached to the $rootElement', function() {
var count = 0; var count = 0;
module(function($animateProvider) { module(function($animateProvider) {
@ -154,6 +160,7 @@ describe("ngAnimate", function() {
}); });
}); });
it('should check enable/disable animations up until the $rootElement element', function() { it('should check enable/disable animations up until the $rootElement element', function() {
var rootElm = jqLite('<div></div>'); var rootElm = jqLite('<div></div>');
@ -195,6 +202,7 @@ describe("ngAnimate", function() {
}); });
}); });
describe("with polyfill", function() { describe("with polyfill", function() {
var child, after; var child, after;
@ -262,6 +270,7 @@ describe("ngAnimate", function() {
}); });
}) })
it("should animate the enter animation event", it("should animate the enter animation event",
inject(function($animate, $rootScope, $sniffer, $timeout) { inject(function($animate, $rootScope, $sniffer, $timeout) {
element[0].removeChild(child[0]); element[0].removeChild(child[0]);
@ -280,6 +289,7 @@ describe("ngAnimate", function() {
expect(element.contents().length).toBe(1); expect(element.contents().length).toBe(1);
})); }));
it("should animate the leave animation event", it("should animate the leave animation event",
inject(function($animate, $rootScope, $sniffer, $timeout) { inject(function($animate, $rootScope, $sniffer, $timeout) {
@ -297,6 +307,7 @@ describe("ngAnimate", function() {
expect(element.contents().length).toBe(0); expect(element.contents().length).toBe(0);
})); }));
it("should animate the move animation event", it("should animate the move animation event",
inject(function($animate, $compile, $rootScope, $timeout, $sniffer) { inject(function($animate, $compile, $rootScope, $timeout, $sniffer) {
@ -316,6 +327,7 @@ describe("ngAnimate", function() {
expect(element.text()).toBe('21'); expect(element.text()).toBe('21');
})); }));
it("should animate the show animation event", it("should animate the show animation event",
inject(function($animate, $rootScope, $sniffer, $timeout) { inject(function($animate, $rootScope, $sniffer, $timeout) {
@ -334,6 +346,7 @@ describe("ngAnimate", function() {
expect(child).toBeShown(); expect(child).toBeShown();
})); }));
it("should animate the hide animation event", it("should animate the hide animation event",
inject(function($animate, $rootScope, $sniffer, $timeout) { inject(function($animate, $rootScope, $sniffer, $timeout) {
@ -349,6 +362,7 @@ describe("ngAnimate", function() {
expect(child).toBeHidden(); expect(child).toBeHidden();
})); }));
it("should assign the ng-event className to all animation events when transitions/keyframes are used", it("should assign the ng-event className to all animation events when transitions/keyframes are used",
inject(function($animate, $sniffer, $rootScope, $timeout) { inject(function($animate, $sniffer, $rootScope, $timeout) {
@ -401,6 +415,7 @@ describe("ngAnimate", function() {
browserTrigger(child,'transitionend', { timeStamp: Date.now() + 1000, elapsedTime: 1 }); browserTrigger(child,'transitionend', { timeStamp: Date.now() + 1000, elapsedTime: 1 });
})); }));
it("should not run if animations are disabled", it("should not run if animations are disabled",
inject(function($animate, $rootScope, $timeout, $sniffer) { inject(function($animate, $rootScope, $timeout, $sniffer) {
@ -425,6 +440,7 @@ describe("ngAnimate", function() {
expect(element.text()).toBe('memento'); expect(element.text()).toBe('memento');
})); }));
it("should only call done() once and right away if another animation takes place in between", it("should only call done() once and right away if another animation takes place in between",
inject(function($animate, $rootScope, $sniffer, $timeout) { inject(function($animate, $rootScope, $sniffer, $timeout) {
@ -457,6 +473,7 @@ describe("ngAnimate", function() {
expect(element.children().length).toBe(0); expect(element.children().length).toBe(0);
})); }));
it("should retain existing styles of the animated element", it("should retain existing styles of the animated element",
inject(function($animate, $rootScope, $sniffer, $timeout) { inject(function($animate, $rootScope, $sniffer, $timeout) {
@ -478,6 +495,7 @@ describe("ngAnimate", function() {
expect(child.attr('style')).toMatch(/width: 20px/i); expect(child.attr('style')).toMatch(/width: 20px/i);
})); }));
it("should call the cancel callback when another animation is called on the same element", it("should call the cancel callback when another animation is called on the same element",
inject(function($animate, $rootScope, $sniffer, $timeout) { inject(function($animate, $rootScope, $sniffer, $timeout) {
@ -495,6 +513,7 @@ describe("ngAnimate", function() {
expect(child.hasClass('animation-cancelled')).toBe(true); expect(child.hasClass('animation-cancelled')).toBe(true);
})); }));
it("should skip a class-based animation if the same element already has an ongoing structural animation", it("should skip a class-based animation if the same element already has an ongoing structural animation",
inject(function($animate, $rootScope, $sniffer, $timeout) { inject(function($animate, $rootScope, $sniffer, $timeout) {
@ -519,6 +538,7 @@ describe("ngAnimate", function() {
expect(completed).toBe(true); expect(completed).toBe(true);
})); }));
it("should fire the cancel/end function with the correct flag in the parameters", it("should fire the cancel/end function with the correct flag in the parameters",
inject(function($animate, $rootScope, $sniffer, $timeout) { inject(function($animate, $rootScope, $sniffer, $timeout) {
@ -557,6 +577,7 @@ describe("ngAnimate", function() {
expect(element.hasClass('custom-long-delay')).toBe(true); expect(element.hasClass('custom-long-delay')).toBe(true);
})); }));
it("should allow both multiple JS and CSS animations which run in parallel", it("should allow both multiple JS and CSS animations which run in parallel",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout, _$rootElement_) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout, _$rootElement_) {
$rootElement = _$rootElement_; $rootElement = _$rootElement_;
@ -588,7 +609,9 @@ describe("ngAnimate", function() {
})); }));
}); });
describe("with CSS3", function() { describe("with CSS3", function() {
beforeEach(function() { beforeEach(function() {
module(function() { module(function() {
return function(_$rootElement_) { return function(_$rootElement_) {
@ -597,7 +620,9 @@ describe("ngAnimate", function() {
}) })
}); });
describe("Animations", function() { describe("Animations", function() {
it("should properly detect and make use of CSS Animations", it("should properly detect and make use of CSS Animations",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
@ -621,6 +646,7 @@ describe("ngAnimate", function() {
expect(element).toBeShown(); expect(element).toBeShown();
})); }));
it("should properly detect and make use of CSS Animations with multiple iterations", it("should properly detect and make use of CSS Animations with multiple iterations",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
@ -645,6 +671,7 @@ describe("ngAnimate", function() {
expect(element).toBeShown(); expect(element).toBeShown();
})); }));
it("should not consider the animation delay is provided", it("should not consider the animation delay is provided",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
@ -671,6 +698,7 @@ describe("ngAnimate", function() {
expect(element).toBeShown(); expect(element).toBeShown();
})); }));
it("should skip animations if disabled and run when enabled", it("should skip animations if disabled and run when enabled",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
$animate.enabled(false); $animate.enabled(false);
@ -687,6 +715,7 @@ describe("ngAnimate", function() {
expect(element).toBeShown(); expect(element).toBeShown();
})); }));
it("should finish the previous animation when a new animation is started", it("should finish the previous animation when a new animation is started",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
var style = '-webkit-animation: some_animation 2s linear 0s 1 alternate;' + var style = '-webkit-animation: some_animation 2s linear 0s 1 alternate;' +
@ -721,6 +750,7 @@ describe("ngAnimate", function() {
expect(element.hasClass('ng-hide-remove-active')).toBe(false); expect(element.hasClass('ng-hide-remove-active')).toBe(false);
})); }));
it("should stagger the items when the correct CSS class is provided", it("should stagger the items when the correct CSS class is provided",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) {
@ -781,6 +811,7 @@ describe("ngAnimate", function() {
expect(elements[4].attr('style')).not.toMatch(/animation-delay: 0\.4\d*s/); expect(elements[4].attr('style')).not.toMatch(/animation-delay: 0\.4\d*s/);
})); }));
it("should stagger items when multiple animation durations/delays are defined", it("should stagger items when multiple animation durations/delays are defined",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) {
@ -817,7 +848,9 @@ describe("ngAnimate", function() {
}); });
describe("Transitions", function() { describe("Transitions", function() {
it("should skip transitions if disabled and run when enabled", it("should skip transitions if disabled and run when enabled",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
@ -848,6 +881,7 @@ describe("ngAnimate", function() {
expect(element).toBeShown(); expect(element).toBeShown();
})); }));
it("should skip animations if disabled and run when enabled picking the longest specified duration", it("should skip animations if disabled and run when enabled picking the longest specified duration",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
@ -875,6 +909,7 @@ describe("ngAnimate", function() {
expect(element).toBeShown(); expect(element).toBeShown();
})); }));
it("should skip animations if disabled and run when enabled picking the longest specified duration/delay combination", it("should skip animations if disabled and run when enabled picking the longest specified duration/delay combination",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
$animate.enabled(false); $animate.enabled(false);
@ -910,6 +945,7 @@ describe("ngAnimate", function() {
expect(element).toBeShown(); expect(element).toBeShown();
})); }));
it("should NOT overwrite styles with outdated values when animation completes", it("should NOT overwrite styles with outdated values when animation completes",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
@ -939,6 +975,7 @@ describe("ngAnimate", function() {
expect(element.css('width')).toBe("200px"); expect(element.css('width')).toBe("200px");
})); }));
it("should animate for the highest duration", it("should animate for the highest duration",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
var style = '-webkit-transition:1s linear all 2s;' + var style = '-webkit-transition:1s linear all 2s;' +
@ -966,6 +1003,7 @@ describe("ngAnimate", function() {
} }
})); }));
it("should finish the previous transition when a new animation is started", it("should finish the previous transition when a new animation is started",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
var style = '-webkit-transition: 1s linear all;' + var style = '-webkit-transition: 1s linear all;' +
@ -998,6 +1036,7 @@ describe("ngAnimate", function() {
} }
})); }));
it("should stagger the items when the correct CSS class is provided", it("should stagger the items when the correct CSS class is provided",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) {
@ -1058,6 +1097,7 @@ describe("ngAnimate", function() {
expect(elements[4].attr('style')).not.toMatch(/transition-delay: 0\.4\d*s/); expect(elements[4].attr('style')).not.toMatch(/transition-delay: 0\.4\d*s/);
})); }));
it("should stagger items when multiple transition durations/delays are defined", it("should stagger items when multiple transition durations/delays are defined",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) {
@ -1092,6 +1132,7 @@ describe("ngAnimate", function() {
expect(elements[3].attr('style')).toMatch(/transition-delay: 2\.3\d*s,\s*4\.3\d*s/); expect(elements[3].attr('style')).toMatch(/transition-delay: 2\.3\d*s,\s*4\.3\d*s/);
})); }));
it("apply a closing timeout to close all pending transitions", it("apply a closing timeout to close all pending transitions",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
@ -1111,6 +1152,7 @@ describe("ngAnimate", function() {
expect(element.hasClass('some-class-add-active')).toBe(false); expect(element.hasClass('some-class-add-active')).toBe(false);
})); }));
it("should not allow the closing animation to close off a successive animation midway", it("should not allow the closing animation to close off a successive animation midway",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
@ -1142,6 +1184,7 @@ describe("ngAnimate", function() {
})); }));
}); });
it("should apply staggering to both transitions and keyframe animations when used within the same animation", it("should apply staggering to both transitions and keyframe animations when used within the same animation",
inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) { inject(function($animate, $rootScope, $compile, $sniffer, $timeout, $document, $rootElement) {
@ -1189,7 +1232,9 @@ describe("ngAnimate", function() {
})); }));
}); });
describe('animation evaluation', function () { describe('animation evaluation', function () {
it('should re-evaluate the CSS classes for an animation each time', it('should re-evaluate the CSS classes for an animation each time',
inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout, $compile) { inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout, $compile) {
@ -1232,6 +1277,7 @@ describe("ngAnimate", function() {
expect(element.hasClass('xyz')).toBe(true); expect(element.hasClass('xyz')).toBe(true);
})); }));
it('should only append active to the newly append CSS className values', it('should only append active to the newly append CSS className values',
inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) {
@ -1266,7 +1312,9 @@ describe("ngAnimate", function() {
})); }));
}); });
describe("Callbacks", function() { describe("Callbacks", function() {
beforeEach(function() { beforeEach(function() {
module(function($animateProvider) { module(function($animateProvider) {
$animateProvider.register('.custom', function($timeout) { $animateProvider.register('.custom', function($timeout) {
@ -1286,6 +1334,7 @@ describe("ngAnimate", function() {
}) })
}); });
it("should fire the enter callback", it("should fire the enter callback",
inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {
@ -1305,6 +1354,7 @@ describe("ngAnimate", function() {
expect(flag).toBe(true); expect(flag).toBe(true);
})); }));
it("should fire the leave callback", it("should fire the leave callback",
inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {
@ -1324,6 +1374,7 @@ describe("ngAnimate", function() {
expect(flag).toBe(true); expect(flag).toBe(true);
})); }));
it("should fire the move callback", it("should fire the move callback",
inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {
@ -1345,6 +1396,7 @@ describe("ngAnimate", function() {
expect(element.parent().id).toBe(parent2.id); expect(element.parent().id).toBe(parent2.id);
})); }));
it("should fire the addClass/removeClass callbacks", it("should fire the addClass/removeClass callbacks",
inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {
@ -1367,6 +1419,7 @@ describe("ngAnimate", function() {
expect(signature).toBe('AB'); expect(signature).toBe('AB');
})); }));
it("should fire a done callback when provided with no animation", it("should fire a done callback when provided with no animation",
inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {
@ -1384,6 +1437,7 @@ describe("ngAnimate", function() {
expect(flag).toBe(true); expect(flag).toBe(true);
})); }));
it("should fire a done callback when provided with a css animation/transition", it("should fire a done callback when provided with a css animation/transition",
inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {
@ -1409,6 +1463,7 @@ describe("ngAnimate", function() {
expect(flag).toBe(true); expect(flag).toBe(true);
})); }));
it("should fire a done callback when provided with a JS animation", it("should fire a done callback when provided with a JS animation",
inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {
@ -1427,6 +1482,7 @@ describe("ngAnimate", function() {
expect(flag).toBe(true); expect(flag).toBe(true);
})); }));
it("should fire the callback right away if another animation is called right after", it("should fire the callback right away if another animation is called right after",
inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {
@ -1454,7 +1510,9 @@ describe("ngAnimate", function() {
})); }));
}); });
describe("addClass / removeClass", function() { describe("addClass / removeClass", function() {
var captured; var captured;
beforeEach(function() { beforeEach(function() {
module(function($animateProvider, $provide) { module(function($animateProvider, $provide) {
@ -1473,6 +1531,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should not perform an animation, and the followup DOM operation, if the class is " + it("should not perform an animation, and the followup DOM operation, if the class is " +
"already present during addClass or not present during removeClass on the element", "already present during addClass or not present during removeClass on the element",
inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) {
@ -1508,6 +1567,7 @@ describe("ngAnimate", function() {
expect(captured).toBe('addClass-some-class'); expect(captured).toBe('addClass-some-class');
})); }));
it("should add and remove CSS classes after an animation even if no animation is present", it("should add and remove CSS classes after an animation even if no animation is present",
inject(function($animate, $rootScope, $sniffer, $rootElement) { inject(function($animate, $rootScope, $sniffer, $rootElement) {
@ -1527,6 +1587,7 @@ describe("ngAnimate", function() {
expect(element.hasClass('klass-remove-active')).toBe(false); expect(element.hasClass('klass-remove-active')).toBe(false);
})); }));
it("should add and remove CSS classes with a callback", it("should add and remove CSS classes with a callback",
inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) {
@ -1552,6 +1613,7 @@ describe("ngAnimate", function() {
expect(signature).toBe('AB'); expect(signature).toBe('AB');
})); }));
it("should end the current addClass animation, add the CSS class and then run the removeClass animation", it("should end the current addClass animation, add the CSS class and then run the removeClass animation",
inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) {
@ -1601,6 +1663,7 @@ describe("ngAnimate", function() {
expect(signature).toBe('12'); expect(signature).toBe('12');
})); }));
it("should properly execute JS animations and use callbacks when using addClass / removeClass", it("should properly execute JS animations and use callbacks when using addClass / removeClass",
inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) {
@ -1630,6 +1693,7 @@ describe("ngAnimate", function() {
expect(signature).toBe('XY'); expect(signature).toBe('XY');
})); }));
it("should properly execute CSS animations/transitions and use callbacks when using addClass / removeClass", it("should properly execute CSS animations/transitions and use callbacks when using addClass / removeClass",
inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) {
@ -1680,6 +1744,7 @@ describe("ngAnimate", function() {
expect(signature).toBe('db'); expect(signature).toBe('db');
})); }));
it("should allow for multiple css classes to be animated plus a callback when added", it("should allow for multiple css classes to be animated plus a callback when added",
inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) {
@ -1721,6 +1786,7 @@ describe("ngAnimate", function() {
expect(flag).toBe(true); expect(flag).toBe(true);
})); }));
it("should allow for multiple css classes to be animated plus a callback when removed", it("should allow for multiple css classes to be animated plus a callback when removed",
inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) { inject(function($animate, $rootScope, $sniffer, $rootElement, $timeout) {
@ -1784,6 +1850,7 @@ describe("ngAnimate", function() {
return element; return element;
} }
it("should properly animate and parse CSS3 transitions", it("should properly animate and parse CSS3 transitions",
inject(function($compile, $rootScope, $animate, $sniffer, $timeout) { inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
@ -1807,6 +1874,7 @@ describe("ngAnimate", function() {
expect(child.hasClass('ng-enter-active')).toBe(false); expect(child.hasClass('ng-enter-active')).toBe(false);
})); }));
it("should properly animate and parse CSS3 animations", it("should properly animate and parse CSS3 animations",
inject(function($compile, $rootScope, $animate, $sniffer, $timeout) { inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
@ -1829,6 +1897,7 @@ describe("ngAnimate", function() {
expect(child.hasClass('ng-enter-active')).toBe(false); expect(child.hasClass('ng-enter-active')).toBe(false);
})); }));
it("should not set the transition property flag if only CSS animations are used", it("should not set the transition property flag if only CSS animations are used",
inject(function($compile, $rootScope, $animate, $sniffer, $timeout) { inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
@ -1863,6 +1932,7 @@ describe("ngAnimate", function() {
expect(child.css(propertyKey)).not.toBe('background-color'); expect(child.css(propertyKey)).not.toBe('background-color');
})); }));
it("should skip animations if the browser does not support CSS3 transitions and CSS3 animations", it("should skip animations if the browser does not support CSS3 transitions and CSS3 animations",
inject(function($compile, $rootScope, $animate, $sniffer) { inject(function($compile, $rootScope, $animate, $sniffer) {
@ -1881,6 +1951,7 @@ describe("ngAnimate", function() {
expect(child.hasClass('ng-enter')).toBe(false); expect(child.hasClass('ng-enter')).toBe(false);
})); }));
it("should run other defined animations inline with CSS3 animations", function() { it("should run other defined animations inline with CSS3 animations", function() {
module(function($animateProvider) { module(function($animateProvider) {
$animateProvider.register('.custom', function($timeout) { $animateProvider.register('.custom', function($timeout) {
@ -1916,6 +1987,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should properly cancel CSS transitions or animations if another animation is fired", function() { it("should properly cancel CSS transitions or animations if another animation is fired", function() {
module(function($animateProvider) { module(function($animateProvider) {
$animateProvider.register('.usurper', function($timeout) { $animateProvider.register('.usurper', function($timeout) {
@ -1962,6 +2034,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should not perform the active class animation if the animation has been cancelled before the reflow occurs", function() { it("should not perform the active class animation if the animation has been cancelled before the reflow occurs", function() {
inject(function($compile, $rootScope, $animate, $sniffer, $timeout) { inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
if(!$sniffer.transitions) return; if(!$sniffer.transitions) return;
@ -1985,6 +2058,7 @@ describe("ngAnimate", function() {
}); });
}); });
//
// it("should add and remove CSS classes and perform CSS animations during the process", // it("should add and remove CSS classes and perform CSS animations during the process",
// inject(function($compile, $rootScope, $animate, $sniffer, $timeout) { // inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
// //
@ -2024,6 +2098,7 @@ describe("ngAnimate", function() {
// expect(element.hasClass('on-remove-active')).toBe(false); // expect(element.hasClass('on-remove-active')).toBe(false);
// })); // }));
// //
//
// it("should show and hide elements with CSS & JS animations being performed in the process", function() { // it("should show and hide elements with CSS & JS animations being performed in the process", function() {
// module(function($animateProvider) { // module(function($animateProvider) {
// $animateProvider.register('.displayer', function($timeout) { // $animateProvider.register('.displayer', function($timeout) {
@ -2084,6 +2159,8 @@ describe("ngAnimate", function() {
// expect(element.hasClass('hiding')).toBe(false); // expect(element.hasClass('hiding')).toBe(false);
// }); // });
// }); // });
it("should remove all the previous classes when the next animation is applied before a reflow", function() { it("should remove all the previous classes when the next animation is applied before a reflow", function() {
var fn, interceptedClass; var fn, interceptedClass;
module(function($animateProvider) { module(function($animateProvider) {
@ -2121,6 +2198,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should provide the correct CSS class to the addClass and removeClass callbacks within a JS animation", function() { it("should provide the correct CSS class to the addClass and removeClass callbacks within a JS animation", function() {
module(function($animateProvider) { module(function($animateProvider) {
$animateProvider.register('.classify', function() { $animateProvider.register('.classify', function() {
@ -2150,6 +2228,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should not skip ngAnimate animations when any pre-existing CSS transitions are present on the element", function() { it("should not skip ngAnimate animations when any pre-existing CSS transitions are present on the element", function() {
inject(function($compile, $rootScope, $animate, $timeout, $sniffer) { inject(function($compile, $rootScope, $animate, $timeout, $sniffer) {
if(!$sniffer.transitions) return; if(!$sniffer.transitions) return;
@ -2178,6 +2257,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should wait until both the duration and delay are complete to close off the animation", it("should wait until both the duration and delay are complete to close off the animation",
inject(function($compile, $rootScope, $animate, $timeout, $sniffer) { inject(function($compile, $rootScope, $animate, $timeout, $sniffer) {
@ -2212,6 +2292,7 @@ describe("ngAnimate", function() {
expect(element.contents().length).toBe(1); expect(element.contents().length).toBe(1);
})); }));
it("should cancel all child animations when a leave or move animation is triggered on a parent element", function() { it("should cancel all child animations when a leave or move animation is triggered on a parent element", function() {
var step, animationState; var step, animationState;
@ -2287,6 +2368,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should wait until a queue of animations are complete before performing a reflow", it("should wait until a queue of animations are complete before performing a reflow",
inject(function($rootScope, $compile, $timeout,$sniffer) { inject(function($rootScope, $compile, $timeout,$sniffer) {
@ -2421,6 +2503,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should not disable any child animations when any parent class-based animations are run", function() { it("should not disable any child animations when any parent class-based animations are run", function() {
var intercepted; var intercepted;
module(function($animateProvider) { module(function($animateProvider) {
@ -2447,6 +2530,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should cache the response from getComputedStyle if each successive element has the same className value and parent until the first reflow hits", function() { it("should cache the response from getComputedStyle if each successive element has the same className value and parent until the first reflow hits", function() {
var count = 0; var count = 0;
module(function($provide) { module(function($provide) {
@ -2493,6 +2577,7 @@ describe("ngAnimate", function() {
}); });
}); });
it("should cancel an ongoing class-based animation only if the new class contains transition/animation CSS code", it("should cancel an ongoing class-based animation only if the new class contains transition/animation CSS code",
inject(function($compile, $rootScope, $animate, $sniffer, $timeout) { inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
@ -2529,6 +2614,7 @@ describe("ngAnimate", function() {
expect(element.hasClass('yellow-add')).toBe(true); expect(element.hasClass('yellow-add')).toBe(true);
})); }));
it("should cancel and perform the dom operation only after the reflow has run", it("should cancel and perform the dom operation only after the reflow has run",
inject(function($compile, $rootScope, $animate, $sniffer, $timeout) { inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
@ -2559,6 +2645,7 @@ describe("ngAnimate", function() {
expect(element.hasClass('red')).toBe(true); expect(element.hasClass('red')).toBe(true);
})); }));
it('should enable and disable animations properly on the root element', function() { it('should enable and disable animations properly on the root element', function() {
var count = 0; var count = 0;
module(function($animateProvider) { module(function($animateProvider) {
@ -2582,6 +2669,7 @@ describe("ngAnimate", function() {
}); });
}); });
it('should perform pre and post animations', function() { it('should perform pre and post animations', function() {
var steps = []; var steps = [];
module(function($animateProvider) { module(function($animateProvider) {
@ -2610,6 +2698,7 @@ describe("ngAnimate", function() {
}); });
}); });
it('should treat the leave event always as a before event and discard the beforeLeave function', function() { it('should treat the leave event always as a before event and discard the beforeLeave function', function() {
var parentID, steps = []; var parentID, steps = [];
module(function($animateProvider) { module(function($animateProvider) {
@ -2643,6 +2732,7 @@ describe("ngAnimate", function() {
}); });
}); });
it('should only perform the DOM operation once', it('should only perform the DOM operation once',
inject(function($sniffer, $compile, $rootScope, $rootElement, $animate, $timeout) { inject(function($sniffer, $compile, $rootScope, $rootElement, $animate, $timeout) {
@ -2677,6 +2767,7 @@ describe("ngAnimate", function() {
expect(element.hasClass('base-class')).toBe(true); expect(element.hasClass('base-class')).toBe(true);
})); }));
it('should block and unblock transitions before the dom operation occurs', it('should block and unblock transitions before the dom operation occurs',
inject(function($rootScope, $compile, $rootElement, $document, $animate, $sniffer, $timeout) { inject(function($rootScope, $compile, $rootElement, $document, $animate, $sniffer, $timeout) {
@ -2710,6 +2801,7 @@ describe("ngAnimate", function() {
expect(capturedProperty).not.toBe('none'); expect(capturedProperty).not.toBe('none');
})); }));
it('should block and unblock keyframe animations around the reflow operation', it('should block and unblock keyframe animations around the reflow operation',
inject(function($rootScope, $compile, $rootElement, $document, $animate, $sniffer, $timeout) { inject(function($rootScope, $compile, $rootElement, $document, $animate, $sniffer, $timeout) {
@ -2736,6 +2828,7 @@ describe("ngAnimate", function() {
expect(node.style[animationKey]).not.toContain('none'); expect(node.style[animationKey]).not.toContain('none');
})); }));
it('should block and unblock keyframe animations before the followup JS animation occurs', function() { it('should block and unblock keyframe animations before the followup JS animation occurs', function() {
module(function($animateProvider) { module(function($animateProvider) {
$animateProvider.register('.special', function($sniffer, $window) { $animateProvider.register('.special', function($sniffer, $window) {
@ -2779,6 +2872,7 @@ describe("ngAnimate", function() {
}); });
}); });
it('should round up long elapsedTime values to close off a CSS3 animation', it('should round up long elapsedTime values to close off a CSS3 animation',
inject(function($rootScope, $compile, $rootElement, $document, $animate, $sniffer, $timeout, $window) { inject(function($rootScope, $compile, $rootElement, $document, $animate, $sniffer, $timeout, $window) {
if (!$sniffer.animations) return; if (!$sniffer.animations) return;
@ -2800,6 +2894,7 @@ describe("ngAnimate", function() {
expect($rootElement.children().length).toBe(0); expect($rootElement.children().length).toBe(0);
})); }));
it('should properly animate elements with compound directives', function() { it('should properly animate elements with compound directives', function() {
var capturedAnimation; var capturedAnimation;
module(function($animateProvider) { module(function($animateProvider) {