本文整理汇总了TypeScript中angular2/http/testing.MockConnection类的典型用法代码示例。如果您正苦于以下问题:TypeScript MockConnection类的具体用法?TypeScript MockConnection怎么用?TypeScript MockConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockConnection类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ResponseOptions
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: this.albums
}
)));
});
示例2: ResponseOptions
xhrBackend.connections.subscribe((connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: JSON.stringify({status: 400, statusText: '400 error'})
})
));
});
示例3: ResponseOptions
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: ['type1','type2','type3']
})
));
});
示例4: ResponseOptions
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: JSON.stringify(userObject)
}
)));
});
示例5: Response
backend.connections.subscribe((connection: MockConnection) => {
connection.mockRespond(
new Response(
new ResponseOptions(responseOptions)
)
);
});
示例6: Response
mockBackend.connections.subscribe((connection: MockConnection) => {
getDataCon = connection;
connection.mockRespond(new Response(new ResponseOptions({
body: {
value: 'webpack-angular2-example'
}
})));
});
示例7: expect
backend.connections.subscribe((connection: MockConnection) => {
expect(connection.request.url).toBe('http://jsonplaceholder.typicode.com/users');
expect(connection.request.method).toBe(RequestMethod.Post);
expect(connection.request.text()).toBe(JSON.stringify(mockUser));
let mockResponseBody: IUser = { id: 11 };
let response = new ResponseOptions({body: JSON.stringify(mockResponseBody)});
connection.mockRespond(new Response(response));
});
示例8: ResponseOptions
backend.connections.subscribe((connection: MockConnection) => {
let mockResponseBody: IAPIRecord[] = [{
title: 'Me',
content: 'Testing is a good thing'
}];
let response = new ResponseOptions({body: JSON.stringify(mockResponseBody)});
connection.mockRespond(new Response(response));
});