Skip to content

Commit

Permalink
fix(ngMock): ignore empty javascript animations in $animate.closeAndF…
Browse files Browse the repository at this point in the history
…lush()
  • Loading branch information
Narretz committed Jan 11, 2016
1 parent cb74999 commit a801df7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,10 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])

var animateJsConstructor = function() {
var animator = $delegate.apply($delegate, arguments);
runners.push(animator);
// If no javascript animation is found, animator is undefined
if (animator) {
runners.push(animator);
}
return animator;
};

Expand Down
22 changes: 22 additions & 0 deletions test/ngMock/angular-mocksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2230,12 +2230,34 @@ describe('ngMockE2E', function() {
expect(animationLog).toEqual(['start leave', 'end leave']);
}));

it('should not throw when a regular animation has no javascript animation',
inject(function($animate, $$animation, $rootElement) {

var element = jqLite('<div></div>');
$rootElement.append(element);

// Make sure the animation has valid $animateCss options
$$animation(element, null, {
from: { background: 'red' },
to: { background: 'blue' },
duration: 1,
transitionStyle: '1s linear all'
});

expect(function() {
$animate.closeAndFlush();
}).not.toThrow();

dealoc(element);
}));

it('should throw an error if there are no animations to close and flush',
inject(function($animate) {

expect(function() {
$animate.closeAndFlush();
}).toThrow('No pending animations ready to be closed or flushed');

}));
});
});
Expand Down

0 comments on commit a801df7

Please sign in to comment.