如何为具有依赖于http的构造函数的以下类编写jasmine测试用例
import {Injectable} from 'angular2/core';
import {Http, HTTP_PROVIDERS} from 'angular2/http';
@Injectable()
export class MockUserService {
items:Array;
constructor(http:Http){
http.get('http://127.0.0.1:8080/src/data/names.json')
.subscribe(res => {
this.items = res;
console.log('results found');
})
}
}
我尝试了以下方式,
it('Testing user login', inject([MockUserService,Http], (mockUserService:MockUserService ) => {
let http:Http;
let mockUserService: MockUserService = new MockUserService(http);
expect(1+1).toEqual(2);
});
);
我收到DI错误: DI错误图片