当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript MockConnection.mockRespond方法代码示例

本文整理汇总了TypeScript中angular2/src/http/backends/mock_backend.MockConnection.mockRespond方法的典型用法代码示例。如果您正苦于以下问题:TypeScript MockConnection.mockRespond方法的具体用法?TypeScript MockConnection.mockRespond怎么用?TypeScript MockConnection.mockRespond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/http/backends/mock_backend.MockConnection的用法示例。


在下文中一共展示了MockConnection.mockRespond方法的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();
 }));
开发者ID:AwelEshetu,项目名称:angular,代码行数:9,代码来源:mock_backend_spec.ts

示例2: Response

 (connection: MockConnection) => {
     connection.mockRespond(new Response(
         new ResponseOptions({
             body: testRes
         }
         )));
 });
开发者ID:Ulbora,项目名称:ContriveCD,代码行数:7,代码来源:edit-domain.serviceSpec.ts

示例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);
                }
开发者ID:Erbolking,项目名称:angular2-testing,代码行数:29,代码来源:my-service.spec.ts

示例4: Response

 mockBackend.connections.subscribe((connection: MockConnection) => {
   if (connection.request.method === RequestMethod.Delete) {
     connection.mockRespond(new Response(new ResponseOptions({
       body: connection.request.text()
     })));
   }
 });
开发者ID:dannylagrouw,项目名称:trivento-angular2-seed,代码行数:7,代码来源:NoteService.spec.ts

示例5: Response

 (connection: MockConnection) => {
     connection.mockRespond(new Response(
         new ResponseOptions({
             body: {
                 user: {
                     id: 1,
                     name: 'stephen'
                 }
             }
         })));
 });
开发者ID:abiodun0,项目名称:ng-2-data,代码行数:11,代码来源:store.service.spec.ts

示例6: Response

 (connection: MockConnection) => {
   connection.mockRespond(new Response(
     new ResponseOptions({
         body: [
           {
             id: 26,
             contentRendered: "<p><b>Hi there</b></p>",
             contentMarkdown: "*Hi there*"
           }]
       }
     )));
 });
开发者ID:liuyijie,项目名称:angular2-webpack-demo-routing-and-http,代码行数:12,代码来源:blog-service.spec.ts

示例7: Response

 (connection: MockConnection) => {
     connection.mockRespond(new Response(
         new ResponseOptions({
             body: [
                 {
                     id: 666,
                     text: 'write a passing test',
                     completed: true
                 }]
         }
         )));
 });
开发者ID:whtouche,项目名称:ng2-auth0-starter,代码行数:12,代码来源:todo.service.spec.ts

示例8: ResponseOptions

                (connection:MockConnection) => {
                    var options = new ResponseOptions({
                        body: {
                            "id": 1,
                            "name": "Roshan Shrestha"
                        }
                    });

                    var response = new Response(options);

                    connection.mockRespond(response);
                }
开发者ID:abhinavmsra,项目名称:angular2,代码行数:12,代码来源:employee-form.component.spec.ts

示例9: ResponseOptions

                (connection:MockConnection) => {
                    var options = new ResponseOptions({
                        body: {
                            "name": "Abhinav Mishra",
                            "id": 1
                        }
                    });

                    var response = new Response(options);

                    connection.mockRespond(response);
                }
开发者ID:abhinavmsra,项目名称:angular2,代码行数:12,代码来源:employee-form-service.component.spec.ts


注:本文中的angular2/src/http/backends/mock_backend.MockConnection.mockRespond方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。