Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5f8bb47

Browse files
committed
test(ngAnimate): ensure the preparation class is added
1 parent 5d0c8d8 commit 5f8bb47

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

test/ngAnimate/animationSpec.js

+19
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,25 @@ describe('$$animation', function() {
513513
expect(captureLog[1].element).toBe(child);
514514
expect(captureLog[2].element).toBe(grandchild);
515515
}));
516+
517+
518+
they('should add the preparation class before the $prop-animation is pushed to the queue',
519+
['enter', 'leave', 'move'], function(animationType) {
520+
inject(function($$animation, $rootScope, $animate) {
521+
var runner = $$animation(element, animationType);
522+
expect(element).toHaveClass('ng-' + animationType + '-prepare');
523+
});
524+
});
525+
526+
527+
they('should remove the preparation class before the $prop-animation starts',
528+
['enter', 'leave', 'move'], function(animationType) {
529+
inject(function($$animation, $rootScope, $$rAF) {
530+
var runner = $$animation(element, animationType);
531+
$rootScope.$digest();
532+
expect(element).not.toHaveClass('ng-' + animationType + '-prepare');
533+
});
534+
});
516535
});
517536

518537
describe("grouped", function() {

test/ngAnimate/integrationSpec.js

+30
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,36 @@ describe('ngAnimate integration tests', function() {
268268
});
269269
});
270270

271+
it('should add the preparation class for a structural animation before a parent animation is applied', function() {
272+
module('ngAnimateMock');
273+
inject(function($animate, $compile, $rootScope, $rootElement, $document, $$rAF) {
274+
element = jqLite(
275+
'<div ng-class="{parent:exp}">' +
276+
'<div ng-if="exp">' +
277+
'</div>' +
278+
'</div>'
279+
);
280+
281+
$rootElement.append(element);
282+
jqLite($document[0].body).append($rootElement);
283+
284+
$compile(element)($rootScope);
285+
$rootScope.exp = true;
286+
$rootScope.$digest();
287+
288+
var outer = element;
289+
var inner = element.find('div');
290+
291+
expect(outer).not.toHaveClass('parent');
292+
expect(inner).toHaveClass('ng-enter-prepare');
293+
294+
$$rAF.flush();
295+
expect(outer).toHaveClass('parent');
296+
expect(inner).not.toHaveClass('ng-enter-prepare');
297+
});
298+
});
299+
300+
271301
it('should pack level elements into their own RAF flush', function() {
272302
module('ngAnimateMock');
273303
inject(function($animate, $compile, $rootScope, $rootElement, $document) {

0 commit comments

Comments
 (0)