當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript testing.MockConnection類代碼示例

本文整理匯總了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
         }
         )));
 });
開發者ID:smithga,項目名稱:musicapp,代碼行數:7,代碼來源:albums.service.spec.ts

示例2: ResponseOptions

 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

示例3: ResponseOptions

 (connection: MockConnection) => {
   connection.mockRespond(new Response(
     new ResponseOptions({
         body: ['type1','type2','type3']
       })
   ));
 });
開發者ID:lsim,項目名稱:mobro,代碼行數:7,代碼來源:model-meta.service.spec.ts

示例4: ResponseOptions

 (connection: MockConnection) => {
   connection.mockRespond(new Response(
     new ResponseOptions({
       body: JSON.stringify(userObject)
     }
     )));
 });
開發者ID:dvelinovska,項目名稱:OPEN_Launcher,代碼行數:7,代碼來源:UserService.spec.ts

示例5: Response

 backend.connections.subscribe((connection: MockConnection) => {
   connection.mockRespond(
     new Response(
       new ResponseOptions(responseOptions)
     )
   );
 });
開發者ID:eporroa,項目名稱:fem-ng2-rest-app,代碼行數:7,代碼來源:items.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: 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

示例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));
      });
開發者ID:bhanuy,項目名稱:ng2-unit-testing-blog,代碼行數:10,代碼來源:quote.service.spec.ts


注:本文中的angular2/http/testing.MockConnection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。