Below is the code for my module declaration:
(angular.module 'services.date', [])
.service '$date', () ->
# stuff
this
This section shows the injection code I am using:
describe 'Service: dateService', () ->
dateService = null
beforeEach module 'services.date'
beforeEach inject (_$date_) ->
dateService = _$date_
describe 'Test', () ->
it 'should test stuff', () ->
(expect true).toBe true
Error message when running the above code:
Firefox 37.0.0 (Ubuntu 0.0.0) Service: dateService Test should test stuff FAILED
minErr/<@/home/pv/Sites/web/ngbp-coffee/vendor/angular/angular.js:68:12
loadModules/<@/home/pv/Sites/web/ngbp-coffee/vendor/angular/angular.js:4411:15
forEach@/home/pv/Sites/web/ngbp-coffee/vendor/angular/angular.js:336:11
loadModules@/home/pv/Sites/web/ngbp-coffee/vendor/angular/angular.js:4372:5
createInjector@/home/pv/Sites/web/ngbp-coffee/vendor/angular/angular.js:4297:11
workFn@/home/pv/Sites/web/ngbp-coffee/vendor/angular-mocks/angular-mocks.js:2172:44
If I comment out the injection code, the test passes as shown below:
describe 'Service: dateService', () ->
# dateService = null
# beforeEach module 'services.date'
# beforeEach inject (_$date_) ->
# dateService = _$date_
describe 'Test', () ->
it 'should test stuff', () ->
(expect true).toBe true
// after running
Firefox 37.0.0 (Ubuntu 0.0.0): Executed 1 of 1 SUCCESS (0.003 secs / 0.002 secs)
Done, without errors.
I seem to be having an issue with how I'm injecting the service. Any assistance would be greatly appreciated.
UPDATE
It appears that the $injector
service is unable to recognize my other service. When I run
$injector.has '$date'
The result is false
What could possibly be wrong in my implementation? Please advise.