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.
This commit is contained in:
Pete Bacon Darwin
2018-12-10 16:43:55 +00:00
parent 264819a308
commit 9ae51d751b
5 changed files with 19 additions and 16 deletions
+1 -1
View File
@@ -57,11 +57,11 @@
"applyInlineStyle": false,
"assertArg": false,
"blockKeyframeAnimations": false,
"blockTransitions": false,
"clearGeneratedClasses": false,
"concatWithSpace": false,
"extractElementNode": false,
"getDomNode": false,
"helpers": false,
"mergeAnimationDetails": false,
"mergeClasses": false,
"packageStyles": false,
+4 -4
View File
@@ -560,7 +560,7 @@ var $AnimateCssProvider = ['$animateProvider', /** @this */ function($animatePro
// that if there is no transition defined then nothing will happen and this will also allow
// other transitions to be stacked on top of each other without any chopping them out.
if (isFirst && !options.skipBlocking) {
blockTransitions(node, SAFE_FAST_FORWARD_DURATION_VALUE);
helpers.blockTransitions(node, SAFE_FAST_FORWARD_DURATION_VALUE);
}
var timings = computeTimings(node, fullClassName, cacheKey, !isStructural);
@@ -646,7 +646,7 @@ var $AnimateCssProvider = ['$animateProvider', /** @this */ function($animatePro
if (flags.blockTransition || flags.blockKeyframeAnimation) {
applyBlocking(maxDuration);
} else if (!options.skipBlocking) {
blockTransitions(node, false);
helpers.blockTransitions(node, false);
}
// 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
}
blockKeyframeAnimations(node, false);
blockTransitions(node, false);
helpers.blockTransitions(node, false);
forEach(temporaryStyles, function(entry) {
// There is only one way to remove inline style properties entirely from elements.
@@ -750,7 +750,7 @@ var $AnimateCssProvider = ['$animateProvider', /** @this */ function($animatePro
function applyBlocking(duration) {
if (flags.blockTransition) {
blockTransitions(node, duration);
helpers.blockTransitions(node, duration);
}
if (flags.blockKeyframeAnimation) {
+11 -9
View File
@@ -329,15 +329,6 @@ function clearGeneratedClasses(element, options) {
}
}
function blockTransitions(node, duration) {
// we use a negative delay value since it performs blocking
// yet it doesn't kill any existing transitions running on the
// same element which makes this safe for class-based animations
var value = duration ? '-' + duration + 's' : '';
applyInlineStyle(node, [TRANSITION_DELAY_PROP, value]);
return [TRANSITION_DELAY_PROP, value];
}
function blockKeyframeAnimations(node, applyBlock) {
var value = applyBlock ? 'paused' : '';
var key = ANIMATION_PROP + ANIMATION_PLAYSTATE_KEY;
@@ -356,3 +347,14 @@ function concatWithSpace(a,b) {
if (!b) return a;
return a + ' ' + b;
}
var helpers = {
blockTransitions: function(node, duration) {
// we use a negative delay value since it performs blocking
// yet it doesn't kill any existing transitions running on the
// same element which makes this safe for class-based animations
var value = duration ? '-' + duration + 's' : '';
applyInlineStyle(node, [TRANSITION_DELAY_PROP, value]);
return [TRANSITION_DELAY_PROP, value];
}
};
+1
View File
@@ -4,6 +4,7 @@
},
"globals": {
"getDomNode": false,
"helpers": false,
"mergeAnimationDetails": false,
"prepareAnimationOptions": false,
"applyAnimationStyles": false,
+2 -2
View File
@@ -1822,7 +1822,7 @@ describe('ngAnimate $animateCss', function() {
they('should not place a CSS transition block if options.skipBlocking is provided',
['enter', 'leave', 'move', 'addClass', 'removeClass'], function(event) {
inject(function($animateCss, $rootElement, $document, $window) {
inject(function($animateCss, $rootElement, $document) {
var element = angular.element('<div></div>');
$rootElement.append(element);
angular.element($document[0].body).append($rootElement);
@@ -1840,7 +1840,7 @@ describe('ngAnimate $animateCss', function() {
data.event = event;
}
var blockSpy = spyOn($window, 'blockTransitions').and.callThrough();
var blockSpy = spyOn(helpers, 'blockTransitions').and.callThrough();
data.skipBlocking = true;
var animator = $animateCss(element, data);