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


TypeScript nock.default方法代码示例

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


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

示例1: testMultpart

 it('should generate valid multipart upload if media and metadata are both set', async () => {
   nock(Utils.baseUrl)
     .post('/upload/drive/v2/files?uploadType=multipart')
     .times(2)
     .reply(201, (uri: string, reqBody: {}) => {
       return reqBody; // return request body as response
       // for testing purposes
     });
   await testMultpart(localDrive);
   await testMultpart(remoteDrive);
 });
开发者ID:google,项目名称:google-api-nodejs-client,代码行数:11,代码来源:test.media.ts

示例2: it

    it('should parse the response body into an object using \'JSON.parse\'', done => {
      const requestHandler = nock('https://api.github.com')
        .intercept('/path', 'method')
        .reply(300, '{"foo": "bar"}');

      (api as any).request('method', '/path').then((data: any) => {
        expect(data).toEqual({foo: 'bar'});
        done();
      });
      requestHandler.done();
    });
开发者ID:DeepanParikh,项目名称:angular,代码行数:11,代码来源:github-api.spec.ts

示例3: it

 it("resolves when request succeeds with response body", () => {
   const body = "body"
   nock(url)
     .get("/")
     .reply(200, body)
   const p = request.send(HTTPMethod.GET, url)
   return Promise.all([
     expect(p).to.be.fulfilled,
     expect(p).to.eventually.be.equal(body),
   ])
 })
开发者ID:pact-foundation,项目名称:pact-js,代码行数:11,代码来源:request.spec.ts

示例4: expect

 it("should return subpaths from shallow get request", async () => {
   nock(serverUrl)
     .get("/.json")
     .query({ shallow: true, limitToFirst: "1234" })
     .reply(200, {
       a: true,
       x: true,
       f: true,
     });
   await expect(remote.listPath("/", 1234)).to.eventually.eql(["a", "x", "f"]);
 });
开发者ID:firebase,项目名称:firebase-tools,代码行数:11,代码来源:listRemote.spec.ts

示例5: Error

 it('should fail if file write fails',  async () => {
   const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(200, ARTIFACT_CONTENTS);
   try {
     WRITEFILE_RESULT = 'Test Error';
     await retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH);
     throw new Error('Exception Expected');
   } catch (error) {
     expect(error.message).toEqual('CircleCI artifact download failed (Test Error)');
   }
   artifactRequest.done();
 });
开发者ID:DeepanParikh,项目名称:angular,代码行数:11,代码来源:build-retriever.spec.ts

示例6: it

 it('should revoke credentials if access token present', async () => {
   const scope = nock('https://accounts.google.com')
                     .get('/o/oauth2/revoke?token=abc')
                     .reply(200, {success: true});
   const oauth2client =
       new googleapis.auth.OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
   oauth2client.credentials = {access_token: 'abc', refresh_token: 'abc'};
   const res = await oauth2client.revokeCredentials();
   assert.equal(res.data.success, true);
   assert.equal(JSON.stringify(oauth2client.credentials), '{}');
 });
开发者ID:sgaluza,项目名称:google-api-nodejs-client,代码行数:11,代码来源:test.auth.ts

示例7: expect

        it("writes the consumer and provider details into the pact", () => {
          nock(mock.baseUrl)
            .post(/pact$/, {
              consumer: { name: "aconsumer" },
              pactfile_write_mode: "overwrite",
              provider: { name: "aprovider" },
            })
            .reply(200)

          return expect(mock.writePact()).to.eventually.be.fulfilled
        })
开发者ID:pact-foundation,项目名称:pact-js,代码行数:11,代码来源:mockService.spec.ts

示例8: testInsert

 it('should return a single response object for single requests', async () => {
   nock(Utils.baseUrl, {allowUnmocked: true})
     .post('/urlshortener/v1/url')
     .times(2)
     .replyWithFile(
       200,
       path.join(__dirname, '../../test/fixtures/urlshort-insert-res.json')
     );
   await testInsert(localUrlshortener);
   await testInsert(remoteUrlshortener);
 });
开发者ID:google,项目名称:google-api-nodejs-client,代码行数:11,代码来源:test.urlshortener.v1.ts


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