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

Commit 6606b4f

Browse files
committed
fixup! fix($animate): improve detection on ng-animate in classNameFilter RegExp
1 parent 5bf4ab0 commit 6606b4f

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

test/ngAnimate/animateSpec.js

+15-21
Original file line numberDiff line numberDiff line change
@@ -257,28 +257,22 @@ describe('animations', function() {
257257

258258
it('should throw a minErr if a regex value is used which partially contains or fully matches the `ng-animate` CSS class',
259259
module(function($animateProvider) {
260-
var errorMessage = '$animateProvider.classNameFilter(regex) prohibits accepting a regex ' +
261-
'value which matches/contains the "ng-animate" CSS class.';
262-
263-
assertError(/ng-animate/, true);
264-
assertError(/first ng-animate last/, true);
265-
assertError(/ng-animate-special/, false);
266-
assertError(/first ng-animate-special last/, false);
267-
assertError(/first ng-animate ng-animate-special last/, true);
268-
assertError(/(ng-animate)/, true);
269-
assertError(/(foo|ng-animate|bar)/, true);
270-
assertError(/(foo|)ng-animate(|bar)/, true);
271-
272-
function assertError(regex, bool) {
273-
var expectation = expect(function() {
260+
expect(setFilter(/ng-animate/)).toThrowMinErr('$animate', 'nongcls');
261+
expect(setFilter(/first ng-animate last/)).toThrowMinErr('$animate', 'nongcls');
262+
expect(setFilter(/first ng-animate ng-animate-special last/)).toThrowMinErr('$animate', 'nongcls');
263+
expect(setFilter(/(ng-animate)/)).toThrowMinErr('$animate', 'nongcls');
264+
expect(setFilter(/(foo|ng-animate|bar)/)).toThrowMinErr('$animate', 'nongcls');
265+
expect(setFilter(/(foo|)ng-animate(|bar)/)).toThrowMinErr('$animate', 'nongcls');
266+
267+
expect(setFilter(/ng-animater/)).not.toThrow();
268+
expect(setFilter(/my-ng-animate/)).not.toThrow();
269+
expect(setFilter(/first ng-animater last/)).not.toThrow();
270+
expect(setFilter(/first my-ng-animate last/)).not.toThrow();
271+
272+
function setFilter(regex) {
273+
return function() {
274274
$animateProvider.classNameFilter(regex);
275-
});
276-
277-
if (bool) {
278-
expectation.toThrowMinErr('$animate', 'nongcls', errorMessage);
279-
} else {
280-
expectation.not.toThrow();
281-
}
275+
};
282276
}
283277
})
284278
);

0 commit comments

Comments
 (0)