Reputation: 1346
(function (angular) {
'use strict';
var testingModule= angular.module('testingModule', []);
testingModule.factory('testService', [ '$q',
function ($q) {
var service = {
get: null
},
tokenDeferred = $q.defer(),
service.getDataWithPromise = function () {
tokenDeferred.resolve({token: this.token, isAuthenticated: true});
}
});
return tokenDeferred.promise;
};
})(angular)
When I am trying to write unit test for this case it always gives me $q undefined, Any Idea what can be wrong?
Below ius the way I am injecting :
beforeEach(inject(function ($q_, _testService_) {
q = $q
fmOauthAccessTokenService = _testService_;
scope = $rootScope.$new();
}));
Upvotes: 0
Views: 139
Reputation: 15070
It should be like this (please note the double underscores surrounding the $q
):
beforeEach(inject(function (_$q_, _testService_) {
q = _$q_;
fmOauthAccessTokenService = _testService_;
scope = $rootScope.$new();
}));
Upvotes: 1