I am currently in the process of writing tests for certain services using karma
and jasmine
. I have a question regarding whether or not I need to mock a service's dependency that utilizes $http
.
PS: I am already utilizing $httpBackend
to mock any GET request, and I intend on utilizing $httpBackend.expect*
if I choose not to mock the ApiProvider
service.
The service I am testing is as follows:
.factory('CRUDService', ['ApiProvider', function (ApiProvider) {
'use strict';
var CRUD = function CRUD(modelName) {
this.getModelName = function () {
return modelName;
};
},
overridableMethods = {
save: null
};
// More code...
}]);
This is the service's dependent service ApiProvider
:
.service('ApiProvider', function ($http) {
// Code for ApiProvider service...
});
And here is how I have conducted tests on the CRUDService so far:
describe('CRUDServiceTest', function () {
'use strict';
// Test cases for CRUDService...
});
TLDR;