尝试获得与Example
类似的行为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
并且转无法读取未定义'的属性'响应'。我做错了什么?