-
-
Save hadrienl/ac1e02059b19880ec378 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('ComponentsMock',[]); | |
angular.module('ComponentsMock') | |
.config(function($provide) { | |
var fixtures = […]; | |
$provide.factory('$http', function() { | |
var $success = null; | |
var $http = function() { | |
var promise = { | |
success: function(callback) { | |
$success = callback; | |
return promise; | |
}, | |
error: function() { | |
return promise; | |
} | |
}; | |
$success = null; | |
return promise; | |
}; | |
$http.flush = function() { | |
if ($success) { | |
$success(fixtures); | |
} | |
}; | |
return $http; | |
}); | |
}) | |
.factory('ComponentsMock', function($injector, $http) { | |
var Components = $injector.get('Components'); | |
Components.$flush = function() { | |
$http.flush(); | |
}; | |
return Components; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment