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

Commit 9ae51d7

Browse files
test(ngAnimate): ensure that blockTransitions can be spied upon
Previously the test was assuing that this function was attached to the window, which is not the case in production, nor in the isolated module tests.
1 parent 264819a commit 9ae51d7

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

src/ngAnimate/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
"applyInlineStyle": false,
5858
"assertArg": false,
5959
"blockKeyframeAnimations": false,
60-
"blockTransitions": false,
6160
"clearGeneratedClasses": false,
6261
"concatWithSpace": false,
6362
"extractElementNode": false,
6463
"getDomNode": false,
64+
"helpers": false,
6565
"mergeAnimationDetails": false,
6666
"mergeClasses": false,
6767
"packageStyles": false,

src/ngAnimate/animateCss.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ var $AnimateCssProvider = ['$animateProvider', /** @this */ function($animatePro
560560
// that if there is no transition defined then nothing will happen and this will also allow
561561
// other transitions to be stacked on top of each other without any chopping them out.
562562
if (isFirst && !options.skipBlocking) {
563-
blockTransitions(node, SAFE_FAST_FORWARD_DURATION_VALUE);
563+
helpers.blockTransitions(node, SAFE_FAST_FORWARD_DURATION_VALUE);
564564
}
565565

566566
var timings = computeTimings(node, fullClassName, cacheKey, !isStructural);
@@ -646,7 +646,7 @@ var $AnimateCssProvider = ['$animateProvider', /** @this */ function($animatePro
646646
if (flags.blockTransition || flags.blockKeyframeAnimation) {
647647
applyBlocking(maxDuration);
648648
} else if (!options.skipBlocking) {
649-
blockTransitions(node, false);
649+
helpers.blockTransitions(node, false);
650650
}
651651

652652
// TODO(matsko): for 1.5 change this code to have an animator object for better debugging
@@ -699,7 +699,7 @@ var $AnimateCssProvider = ['$animateProvider', /** @this */ function($animatePro
699699
}
700700

701701
blockKeyframeAnimations(node, false);
702-
blockTransitions(node, false);
702+
helpers.blockTransitions(node, false);
703703

704704
forEach(temporaryStyles, function(entry) {
705705
// There is only one way to remove inline style properties entirely from elements.
@@ -750,7 +750,7 @@ var $AnimateCssProvider = ['$animateProvider', /** @this */ function($animatePro
750750

751751
function applyBlocking(duration) {
752752
if (flags.blockTransition) {
753-
blockTransitions(node, duration);
753+
helpers.blockTransitions(node, duration);
754754
}
755755

756756
if (flags.blockKeyframeAnimation) {

src/ngAnimate/shared.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,6 @@ function clearGeneratedClasses(element, options) {
329329
}
330330
}
331331

332-
function blockTransitions(node, duration) {
333-
// we use a negative delay value since it performs blocking
334-
// yet it doesn't kill any existing transitions running on the
335-
// same element which makes this safe for class-based animations
336-
var value = duration ? '-' + duration + 's' : '';
337-
applyInlineStyle(node, [TRANSITION_DELAY_PROP, value]);
338-
return [TRANSITION_DELAY_PROP, value];
339-
}
340-
341332
function blockKeyframeAnimations(node, applyBlock) {
342333
var value = applyBlock ? 'paused' : '';
343334
var key = ANIMATION_PROP + ANIMATION_PLAYSTATE_KEY;
@@ -356,3 +347,14 @@ function concatWithSpace(a,b) {
356347
if (!b) return a;
357348
return a + ' ' + b;
358349
}
350+
351+
var helpers = {
352+
blockTransitions: function(node, duration) {
353+
// we use a negative delay value since it performs blocking
354+
// yet it doesn't kill any existing transitions running on the
355+
// same element which makes this safe for class-based animations
356+
var value = duration ? '-' + duration + 's' : '';
357+
applyInlineStyle(node, [TRANSITION_DELAY_PROP, value]);
358+
return [TRANSITION_DELAY_PROP, value];
359+
}
360+
};

test/ngAnimate/.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
},
55
"globals": {
66
"getDomNode": false,
7+
"helpers": false,
78
"mergeAnimationDetails": false,
89
"prepareAnimationOptions": false,
910
"applyAnimationStyles": false,

test/ngAnimate/animateCssSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ describe('ngAnimate $animateCss', function() {
18221822
they('should not place a CSS transition block if options.skipBlocking is provided',
18231823
['enter', 'leave', 'move', 'addClass', 'removeClass'], function(event) {
18241824

1825-
inject(function($animateCss, $rootElement, $document, $window) {
1825+
inject(function($animateCss, $rootElement, $document) {
18261826
var element = angular.element('<div></div>');
18271827
$rootElement.append(element);
18281828
angular.element($document[0].body).append($rootElement);
@@ -1840,7 +1840,7 @@ describe('ngAnimate $animateCss', function() {
18401840
data.event = event;
18411841
}
18421842

1843-
var blockSpy = spyOn($window, 'blockTransitions').and.callThrough();
1843+
var blockSpy = spyOn(helpers, 'blockTransitions').and.callThrough();
18441844

18451845
data.skipBlocking = true;
18461846
var animator = $animateCss(element, data);

0 commit comments

Comments
 (0)