本文整理汇总了TypeScript中angular2/src/http/backends/mock_backend.MockConnection类的典型用法代码示例。如果您正苦于以下问题:TypeScript MockConnection类的具体用法?TypeScript MockConnection怎么用?TypeScript MockConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockConnection类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: inject
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
let connection1: MockConnection = backend.createConnection(sampleRequest1);
let connection2: MockConnection = backend.createConnection(sampleRequest1);
connection1.response.subscribe(() => { async.done(); });
connection2.response.subscribe(() => {});
connection2.mockRespond(sampleResponse1);
connection1.mockRespond(sampleResponse1);
backend.verifyNoPendingRequests();
}));
示例2: ResponseOptions
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: testRes
}
)));
});
示例3: ResponseOptions
(connection:MockConnection) => {
var options = new ResponseOptions({
body: [
{
"login": "mojombo",
"id": 1,
"avatar_url": "https://avatars.githubusercontent.com/u/1?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/mojombo",
"html_url": "https://github.com/mojombo",
"followers_url": "https://api.github.com/users/mojombo/followers",
"following_url": "https://api.github.com/users/mojombo/following{/other_user}",
"gists_url": "https://api.github.com/users/mojombo/gists{/gist_id}",
"starred_url": "https://api.github.com/users/mojombo/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mojombo/subscriptions",
"organizations_url": "https://api.github.com/users/mojombo/orgs",
"repos_url": "https://api.github.com/users/mojombo/repos",
"events_url": "https://api.github.com/users/mojombo/events{/privacy}",
"received_events_url": "https://api.github.com/users/mojombo/received_events",
"type": "User",
"site_admin": false
}
]
});
var response = new Response(options);
connection.mockRespond(response);
}
示例4: Response
mockBackend.connections.subscribe((connection: MockConnection) => {
if (connection.request.method === RequestMethod.Delete) {
connection.mockRespond(new Response(new ResponseOptions({
body: connection.request.text()
})));
}
});
示例5: ResponseOptions
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: {
user: {
id: 1,
name: 'stephen'
}
}
})));
});
示例6: ResponseOptions
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: [
{
id: 26,
contentRendered: "<p><b>Hi there</b></p>",
contentMarkdown: "*Hi there*"
}]
}
)));
});
示例7: ResponseOptions
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: [
{
id: 666,
text: 'write a passing test',
completed: true
}]
}
)));
});
示例8: ResponseOptions
(connection:MockConnection) => {
var options = new ResponseOptions({
body: {
"id": 1,
"name": "Roshan Shrestha"
}
});
var response = new Response(options);
connection.mockRespond(response);
}
示例9: ResponseOptions
(connection:MockConnection) => {
var options = new ResponseOptions({
body: {
"name": "Abhinav Mishra",
"id": 1
}
});
var response = new Response(options);
connection.mockRespond(response);
}