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


TypeScript MockConnection.mockRespond方法代码示例

本文整理汇总了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'})
     })
   ));
 });
开发者ID:AdamFaron,项目名称:FOO,代码行数:7,代码来源:user.service.spec.ts

示例2: Response

 backend.connections.subscribe((connection: MockConnection) => {
   connection.mockRespond(
     new Response(
       new ResponseOptions(responseOptions)
     )
   );
 });
开发者ID:eporroa,项目名称:fem-ng2-rest-app,代码行数:7,代码来源:items.spec.ts

示例3: Response

 (connection: MockConnection) => {
     connection.mockRespond(new Response(
         new ResponseOptions({
             body: this.albums
         }
         )));
 });
开发者ID:smithga,项目名称:musicapp,代码行数:7,代码来源:albums.service.spec.ts

示例4: Response

 (connection: MockConnection) => {
   connection.mockRespond(new Response(
     new ResponseOptions({
       body: JSON.stringify(userObject)
     }
     )));
 });
开发者ID:dvelinovska,项目名称:OPEN_Launcher,代码行数:7,代码来源:UserService.spec.ts

示例5: Response

 (connection: MockConnection) => {
   connection.mockRespond(new Response(
     new ResponseOptions({
         body: ['type1','type2','type3']
       })
   ));
 });
开发者ID:lsim,项目名称:mobro,代码行数:7,代码来源:model-meta.service.spec.ts

示例6: Response

 mockBackend.connections.subscribe((connection: MockConnection) => {
   getDataCon = connection;
   connection.mockRespond(new Response(new ResponseOptions({
     body: {
       value: 'webpack-angular2-example'
     }
   })));
 });
开发者ID:narr,项目名称:webpack-angular2-example,代码行数:8,代码来源:title.spec.ts

示例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));
      });
开发者ID:bhanuy,项目名称:ng2-unit-testing-blog,代码行数:10,代码来源:quote.service.spec.ts

示例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));
 });
开发者ID:Cayan,项目名称:angular2-unit-test-app,代码行数:10,代码来源:user.service.spec.ts


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