Можно ли переопределить или переопределить отклик в mockinged $httpBackend?
У меня такой тест:
beforeEach(inject(function ($rootScope, $controller, _$httpBackend_) {
$httpBackend = _$httpBackend_;
//Fake Backend
$httpBackend.when('GET', '/myUrl').respond({}); //Empty data from server
...some more fake url responses...
}
Это нормально для большинства случаев, но у меня мало тестов, где мне нужно вернуть что-то другое для одного и того же URL-адреса. Но кажется, что после того, как определено значение if(). Response(), я не могу изменить его впоследствии в коде следующим образом:
Различные ответы в одном конкретном тесте:
it('should work', inject(function($controller){
$httpBackend.when('GET', '/myUrl').respond({'some':'very different value with long text'})
//Create controller
//Call the url
//expect that {'some':'very different value with long text'} is returned
//but instead I get the response defined in beforeEach
}));
Как мне это сделать? Мой код теперь не тестируемый: (