Created
February 4, 2014 01:46
-
-
Save forforf/8796063 to your computer and use it in GitHub Desktop.
angular dependency mocking
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
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