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


TypeScript HttpTestingController.match方法代码示例

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


在下文中一共展示了HttpTestingController.match方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should see if rates are available', () => {
    service.updateRatesBtc().then(() => {
      expect(service.isBtcAvailable()).toBe(true);
    });

    httpMock.match(btcUrl)[1].flush(btcResponse);
    httpMock.match(bchUrl)[0].flush(bchResponse);
    httpMock.verify();
  });
开发者ID:bitpay,项目名称:copay,代码行数:9,代码来源:rate.spec.ts

示例2: it

  it('can test multiple requests', () => {
    let testData: Data[] = [
      { name: 'bob' }, { name: 'carol' },
      { name: 'ted' }, { name: 'alice' }
    ];

    // Make three requests in a row
    httpClient.get<Data[]>(testUrl)
      .subscribe(d => expect(d.length).toEqual(0, 'should have no data'));

    httpClient.get<Data[]>(testUrl)
      .subscribe(d => expect(d).toEqual([testData[0]], 'should be one element array'));

    httpClient.get<Data[]>(testUrl)
      .subscribe(d => expect(d).toEqual(testData, 'should be expected data'));

    // get all pending requests that match the given URL
    const requests = httpTestingController.match(testUrl);
    expect(requests.length).toEqual(3);

    // Respond to each request with different results
    requests[0].flush([]);
    requests[1].flush([testData[0]]);
    requests[2].flush(testData);
  });
开发者ID:iproduct,项目名称:course-angular,代码行数:25,代码来源:http-client.spec.ts

示例3: it

 it('should match', () => {
   service.get(url).subscribe();
   backend.match((request) => {
     return request.url.match(/posts/) &&
            request.method === 'GET';
   });
   backend.verify();
 });
开发者ID:dgdavidgreene,项目名称:AngularProjectBase,代码行数:8,代码来源:data.service.spec.ts

示例4: it

    it('init', () => {
      authenticationService.init();
      authenticationService.onLoginEvent.getValue();

      const req = mockBackend.match('/api/v1/user');
      req[1].flush('user');
      expect(req[1].request.method).toBe('GET');
      expect(authenticationService.onLoginEvent.getValue()).toEqual(true);
    });
开发者ID:JonZeolla,项目名称:incubator-metron,代码行数:9,代码来源:authentication.service.spec.ts


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