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

Commit 6fb1915

Browse files
committed
fix(ngMock): throw more descriptive errors for $animate.flushNext()
1 parent d378f55 commit 6fb1915

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/ngMock/angular-mocks.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ angular.mock.$IntervalProvider = function() {
562562
*/
563563
(function() {
564564
var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
565-
565+
566566
function jsonStringToDate(string) {
567567
var match;
568568
if (match = string.match(R_ISO8061_STR)) {
@@ -776,7 +776,12 @@ angular.mock.animate = angular.module('mock.animate', ['ng'])
776776
enabled : $delegate.enabled,
777777
flushNext : function(name) {
778778
var tick = animate.queue.shift();
779-
expect(tick.method).toBe(name);
779+
780+
if (!tick) throw new Error('No animation to be flushed');
781+
if(tick.method !== name) {
782+
throw new Error('The next animation is not "' + name +
783+
'", but is "' + tick.method + '"');
784+
}
780785
tick.fn();
781786
return tick;
782787
}
@@ -1191,7 +1196,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
11911196
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
11921197
* request is handled.
11931198
*
1194-
* - respond –
1199+
* - respond –
11951200
* `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
11961201
* – The respond method takes a set of static data to be returned or a function that can return
11971202
* an array containing response status (number), response data (string) and response headers
@@ -2122,4 +2127,4 @@ angular.mock.clearDataCache = function() {
21222127
}
21232128
}
21242129
};
2125-
})(window);
2130+
})(window);

0 commit comments

Comments
 (0)