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

Commit

Permalink
fix(ngMock): throw more descriptive errors for $animate.flushNext()
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbcross committed Nov 6, 2013
1 parent d378f55 commit 6fb1915
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ angular.mock.$IntervalProvider = function() {
*/
(function() {
var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;

function jsonStringToDate(string) {
var match;
if (match = string.match(R_ISO8061_STR)) {
Expand Down Expand Up @@ -776,7 +776,12 @@ angular.mock.animate = angular.module('mock.animate', ['ng'])
enabled : $delegate.enabled,
flushNext : function(name) {
var tick = animate.queue.shift();
expect(tick.method).toBe(name);

if (!tick) throw new Error('No animation to be flushed');
if(tick.method !== name) {
throw new Error('The next animation is not "' + name +
'", but is "' + tick.method + '"');
}
tick.fn();
return tick;
}
Expand Down Expand Up @@ -1191,7 +1196,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled.
*
* - respond –
* - respond –
* `{function([status,] data[, headers])|function(function(method, url, data, headers)}`
* – The respond method takes a set of static data to be returned or a function that can return
* an array containing response status (number), response data (string) and response headers
Expand Down Expand Up @@ -2122,4 +2127,4 @@ angular.mock.clearDataCache = function() {
}
}
};
})(window);
})(window);

0 comments on commit 6fb1915

Please sign in to comment.