Skip to content

Commit

Permalink
fix($animate): correctly access minErr
Browse files Browse the repository at this point in the history
ngMinErr is not available in the build, but it is available
during unit tests. The added tests don't actually catch this error,
they have just been added for completeness.
  • Loading branch information
Narretz committed Dec 8, 2015
1 parent 193153c commit 458db13
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ngAnimate/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var isPromiseLike = function(p) {
return p && p.then ? true : false;
};

var ngMinErr = angular.$$minErr('ng');

This comment has been minimized.

Copy link
@matsko

matsko Dec 9, 2015

Oops how did I miss that one.

This comment has been minimized.

Copy link
@matsko

matsko Dec 9, 2015

It should also be 'ngAnimate' instead of 'ng' for the module name.

function assertArg(arg, name, reason) {
if (!arg) {
throw ngMinErr('areq', "Argument '{0}' is {1}", (name || '?'), (reason || "required"));
Expand Down
19 changes: 18 additions & 1 deletion test/ngAnimate/animateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,24 @@ describe("animations", function() {
});
}));

it('should allow an element to pinned elsewhere and still be available in animations',
it('should complain if the arguments are not elements',
inject(function($animate, $compile, $document, $rootScope, $rootElement) {

var element = jqLite('<div></div>');

expect(function() {
$animate.pin(element);
}).toThrow();

This comment has been minimized.

Copy link
@matsko

matsko Dec 9, 2015

Now that ngMinErr works, be sure to assert to see that it's actually a min error:

.toThrowMinErr('ngAnimate','areq', "Argument 'parentElement' is not an element");

expect(function() {
$animate.pin(null, $rootElement);
}).toThrow();

This comment has been minimized.

Copy link
@matsko

matsko Dec 9, 2015

And...

.toThrowMinErr('ngAnimate','areq', "Argument 'element' is not an element");

This comment has been minimized.

Copy link
@Narretz

Narretz Dec 10, 2015

Author Owner

There is no actual error description page for ngAnimate[areq], so I would just access the ng[areq] error. I think that's okay because argument required is a very generic error.


dealoc(element);
}));


it('should allow an element to be pinned elsewhere and still be available in animations',
inject(function($animate, $compile, $document, $rootElement, $rootScope) {

var innerParent = jqLite('<div></div>');
Expand Down

0 comments on commit 458db13

Please sign in to comment.