本文整理匯總了TypeScript中angular2/http/testing.MockConnection.mockRespond方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript MockConnection.mockRespond方法的具體用法?TypeScript MockConnection.mockRespond怎麽用?TypeScript MockConnection.mockRespond使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular2/http/testing.MockConnection
的用法示例。
在下文中一共展示了MockConnection.mockRespond方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Response
xhrBackend.connections.subscribe((connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: JSON.stringify({status: 400, statusText: '400 error'})
})
));
});
示例2: Response
backend.connections.subscribe((connection: MockConnection) => {
connection.mockRespond(
new Response(
new ResponseOptions(responseOptions)
)
);
});
示例3: Response
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: this.albums
}
)));
});
示例4: Response
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: JSON.stringify(userObject)
}
)));
});
示例5: Response
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: ['type1','type2','type3']
})
));
});
示例6: Response
mockBackend.connections.subscribe((connection: MockConnection) => {
getDataCon = connection;
connection.mockRespond(new Response(new ResponseOptions({
body: {
value: 'webpack-angular2-example'
}
})));
});
示例7: 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));
});
示例8: 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));
});