我有一個測試(從AngularDart項目中使用茉莉語法)MockHttpBackend - 意外的請求
describe("MockHttpBackend",() {
beforeEach(() {
setUpInjector();
module((Module module) {
module
..type(HttpBackend, implementedBy: MockHttpBackend);
// ..value(HttpBackend, new MockHttpBackend()); // same problem
});
});
it('should do basic request', async(inject((Http http, MockHttpBackend backend) {
backend.expect('GET', '/url').respond('');
http(url: '/url', method: 'GET');
})));
導致
Test failed: Caught [Async error, [Unexpected request: GET /url No more requests expected],
#0 > MockHttpBackend.call (package:angular/mock/http_backend.dart:224:5)
#1 MockHttpBackend.request (package:angular/mock/http_backend.dart:137:9)
任何想法,我做錯了嗎?
看起來http請求不使用相同的HttpBackend我注入,但爲什麼? –