I want to define tests for my angular app but I don't know how to work with because it's my first time to write tests.
However, it's important for me to define Tests with Jasmine for REST Service in my application. Well, my question is how can I test the GET requests. I was on the jasmine site and have read the sample there. But it was only a test whether the URL is correctly written.
My intention is to check if I get response data back? Is that possible? Also in Angular Doc is written that for $resource is $httpBackend recommended. That's why I'm a bit confused how starting define the tests.
At first my services:
resService:
testApp.factory('ResService', ['$resource', 'baseUrl',
function ($resource, baseUrl) {
return {
group: $resource(baseUrl + '/api/qr_group/:Id', {
Id: '@Id'
}, {})
}
}]);
CrudService:
...
getAllGroups: function () {
return ResService.group.query();
},
At last my Controller with the request:
TestCtrl:
CrudService.getAllGroups().$promise.then(
function (response) { $scope.groups = response; },
function (error) { errMessage(error); }
);
Do anyone has an idea? It would be helpful :)