那是代码:
import {
async,
inject,
TestBed
} from '@angular/core/testing';
import {
Http,
Response,
ResponseOptions,
RequestOptions,
BaseRequestOptions,
ConnectionBackend
} from "@angular/http";
import {MockBackend, MockConnection} from "@angular/http/testing";
import {HttpInterceptor, RequestWrapped} from "./http.interceptor.service.ts";
describe("Http interceptor", () => {
beforeEach(() =>{
TestBed.configureTestingModule({
providers: [
MockBackend,
BaseRequestOptions,
{provide: ConnectionBackend, useClass: MockBackend},
{provide: RequestOptions, useClass: BaseRequestOptions},
Http
],
});
});
it('should get blogs', inject([Http, MockBackend], (http:Http, backend:MockBackend) => {
let connection:MockConnection;
backend.connections.subscribe(connection =>
connection.mockRespond(new Response(new ResponseOptions('awesome')))
);
http.request('data.json').subscribe((res) => {
expect(res.text()).toBe('awesome2');
});
}));
});
这个测试应该失败,显然awesome 不等于awesome2,为什么不工作?