I'm trying to test a service of my Angular app with Karma, but I got an error I can't solve : "[$injector:unpr] Unknown provider: $issueProvider <- $issue"
Here is the beginning of the service I want to test :
angular.module("aq.kiosk.api.issue.services")
.service("$issue", ["$q", "$log", "IssueResource", "IssueModel", "$user", "Config", "DateUtils", "$kioskCache", "$filter", "$modal", "$loadingTasks", "$bridge",
function ($q, $log, IssueResource, IssueModel, $user, Config, DateUtils, $kioskCache, $filter, $modal, $loadingTasks, $bridge) {
this.get = function (issueId) {
var defered = $q.defer();
var issueCache = $kioskCache.getGlobalMap(issueId);
if (angular.isDefined(issueCache)) {
defered.resolve(issueCache);
}
else {
var data = {
issueId: issueId
};
IssueResource.get({}, data,
function (result) {
var formattedIssue = undefined;
if (result && result.data && result.data.issue) {
formattedIssue = _getNormalizedIssue(result.data.issue);
formattedIssue = new IssueModel(formattedIssue);
_checkIssueDownloaded(formattedIssue);
$kioskCache.setGlobalMap(formattedIssue);
defered.resolve(formattedIssue);
}
else {
defered.resolve(undefined)
}
},
function (response) {
defered.reject(response)
}
);
}
return defered.promise;
};
And here is my test file :
describe('API Account Service', function () {
// Inject the module and the service.
var Config, $account, $httpBackend, IssueModel, $issue, $kioskCache;
beforeEach(module("aq.kiosk.api.config"));
beforeEach(module("aq.kiosk.api.account.services"));
beforeEach(module("aq.kiosk.api.issue.services"));
beforeEach(module("aq.kiosk.api.cache"));
beforeEach(inject(function (_Config_, _$httpBackend_, _$issue_, _$account_, _IssueModel_, _$kioskCache_ ) {
Config = _Config_;
$account = _$account_;
$issue = _$issue_;
$httpBackend = _$httpBackend_;
IssueModel = _IssueModel_;
$kioskCache = _$kioskCache_;
}));
describe('#get()', function () {
it("should be defined", function () {
$issue.get.should.be.ok;
});
});
});
I pretty sure my mistake come from the inject, but I don't know what exactly. (And I think I have the good files in my karma.conf.js)
Any idea ? Thank you very much
Aucun commentaire:
Enregistrer un commentaire