试图获得与示例中类似的行为
UnitTest.coffee:
describe 'Unit: EditAccessController', ->
...
(var $httpBackend, personRequestHandler)
personUrl = /\/people\/\d+/
testPerson = { personId: 123 }
...
beforeEach inject ($injector) ->
...
# Set up the mock http service responses
$httpBackend = $injector.get '$httpBackend'
personRequestHandler = $httpBackend.whenGET(personUrl).respond(testPerson)
console.log(personRequestHandler) # undefined
...
it 'should ....', ->
personRequestHandler.respond(404, { errors: [{ message: 'Person not found' }] })
...
不知何故respond()
不返回reguestHandler
并转为Can not read property 'respond' of undefined'。我究竟做错了什么?