When testing my REST service I'm getting the following error message:
Error: [$resource:badcfg] query http://ift.tt/1KuyNME$resource/badcfg?p0=array&p1=object&p2=GET&p3=http%3A%2F%2Flocalhost%3A63831%2Fapi%2Fnames in http://localhost:60694/js/angular.js (line 68)
I don't know how to solve the problem. Is it possible that the app is in another localhost port as the WebApi?
The code below is showing the unit-test:
describe('Test', function () {
var $httpBackend, $rootScope, crudService, baseUrl, respValue;
beforeEach(function () {
module('testApp');
inject(function (_$httpBackend_, _$rootScope_, _CrudService_, _baseUrl_) {
$httpBackend = _$httpBackend_;
$rootScope = _$rootScope_;
crudService = _CrudService_;
baseUrl = _baseUrl_;
});
});
it('should make a request to the backend', function () {
$httpBackend.whenGET('views/home.html').respond(200);
$httpBackend.expectGET(baseUrl + '/api/names').respond(200, {
Id: '1', fname: 'John', lname: 'Doe', age: 30, GroupId: 1
});
$rootScope.$digest();
crudService.getAllNames().$promise.then(function (response) {
respValue = response;
});
$httpBackend.flush();
});
});
Aucun commentaire:
Enregistrer un commentaire