Skip to content

Instantly share code, notes, and snippets.

@forforf
Created February 4, 2014 01:46
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 forforf/8796063 to your computer and use it in GitHub Desktop.
Save forforf/8796063 to your computer and use it in GitHub Desktop.
angular dependency mocking
describe('RepoFetcherRatings', function(){
beforeEach( function(){
// mock factory objects
var fetchMock = {
fetcher:function(){
//fake promise
var then = function(){
return [{}, {}, {}];
};
return {
then: then
};
}
};
// mock module dependency
angular.module('GithubRepoFetcher', [])
//mock factory
.factory('GithubRepo', function(){
return fetchMock;
});
//initialize mock
module('GithubRepoFetcher');
//initialize module under test
module('RepoFetcherRatings');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment