I'm testing my Angular controller using mock data pulled in from a JSON file. The problem I'm running into is that my controller expects a promise, whereas my mock data is simply a JSON object.
Relevant controller code:
var vm = this;
var playerId = $routeParams.playerId;
playersService.getInfo({
playerId: playerId
}).$promise.then(function(info) {
vm.info = info;
});
Relevant test code:
$httpBackend = $injector.get('$httpBackend');
jasmine.getJSONFixtures().fixturesPath = 'base/test/fixtures';
$httpBackend.whenGET('/api/players/5/info').respond(
getJSONFixture('info.json')
);
I'm trying to work out how to setup my test to work with the controller's promise structure.
Aucun commentaire:
Enregistrer un commentaire