Skip to content

Instantly share code, notes, and snippets.

@hadrienl
Created April 22, 2014 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadrienl/ac1e02059b19880ec378 to your computer and use it in GitHub Desktop.
Save hadrienl/ac1e02059b19880ec378 to your computer and use it in GitHub Desktop.
'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