I've written a Factory with AngularJs which have a method that returns an http promise.
'use strict'
angular.module('projDefinitApp')
.factory 'testService', ($http) ->
{ getTest: (testID) ->
$http.get "temp/test.json"
}
I'm having some issues when making a test, using karma and Jasmine. The promise didn't return any result. I tried to create a var, then call the function and change the value of the var. But it does not updates the value:
'use strict'
describe 'Service: testService', ->
# load the service's module
beforeEach module 'projDefinitApp'
# instantiate service
testService = {}
beforeEach inject (_testService_) ->
testService = _testService_
it 'should do something', ->
retrieved = undefined
testService.getTest().success ($data,retrieved) ->
retrieved = $data
return
expect(retrieved).toBe(null)
return
return
The console exit looks like this
PhantomJS 1.9.8 (Linux) Service: testService should do something FAILED
Expected undefined to be null.