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


TypeScript nock类代码示例

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


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

示例1: it

 it('should fail if the artifact is too large', async () => {
   const artifactRequest = nock(BASE_URL).get(ARTIFACT_PATH).reply(200, ARTIFACT_CONTENTS);
   retriever = new BuildRetriever(api, 10, DOWNLOAD_DIR);
   try {
     await retriever.downloadBuildArtifact(12345, 777, 'COMMIT', ARTIFACT_PATH);
     throw new Error('Exception Expected');
   } catch (error) {
     expect(error.status).toEqual(413);
   }
   artifactRequest.done();
 });
开发者ID:BobChao87,项目名称:angular,代码行数:11,代码来源:build-retriever.spec.ts

示例2: it

  it("should add required Vary headers to the response", async () => {
    nock(cloudRunApiOrigin)
      .get("/v1alpha1/projects/project-foo/locations/us-central1/services/helloworld")
      .reply(200, { status: { address: { hostname: cloudRunServiceOrigin } } });
    nock(cloudRunServiceOrigin)
      .get("/vary")
      .reply(200, "live vary version", { vary: "Other, Authorization" });

    const mwGenerator = await cloudRunProxy(fakeOptions);
    const mw = await mwGenerator(fakeRewrite);
    const spyMw = sinon.spy(mw);

    return supertest(spyMw)
      .get("/vary")
      .expect(200, "live vary version")
      .then((res) => {
        expect(spyMw.calledOnce).to.be.true;
        expect(res.header.vary).to.equal("Other, Authorization, Accept-Encoding, Cookie");
      });
  });
开发者ID:firebase,项目名称:firebase-tools,代码行数:20,代码来源:cloudRunProxy.spec.ts

示例3: it

 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:dmytrobanasko,项目名称:google-api-nodejs-client,代码行数:11,代码来源:test.urlshortener.v1.ts

示例4: it

 it('should allow overriding validateStatus', async () => {
   const scope = nock(Utils.baseUrl).get('/drive/v2/files').reply(500);
   const google = new GoogleApis();
   const drive = google.drive('v2');
   const res = await drive.files.list({}, {
     validateStatus: (status: number) => {
       return true;
     }
   });
   assert.equal(res.status, 500);
 });
开发者ID:sgaluza,项目名称:google-api-nodejs-client,代码行数:11,代码来源:test.options.ts

示例5: it

 it('should upload a video', async () => {
   const scope =
       nock(Utils.baseUrl)
           .post(
               `/upload/youtube/v3/videos?part=id%2Csnippet%2Cstatus&notifySubscribers=false&uploadType=multipart`)
           .reply(200, {kind: 'youtube#video'});
   const data = await samples.upload.runSample(someFile);
   assert(data);
   assert.strictEqual(data.kind, 'youtube#video');
   scope.done();
 });
开发者ID:perryao,项目名称:google-api-nodejs-client,代码行数:11,代码来源:test.samples.youtube.ts

示例6: function

util.setupExpectedWSTrustRequestCommon = function () {
  var RSTRDoc = fs.readFileSync(parameters.RSTRFile, 'utf8');
  var wstrustRequest = nock(parameters.adfsUrlNoPath)
    .filteringRequestBody(function () { return '*'; })
    .post(parameters.adfsWsTrustPath, '*')
    .reply(200, RSTRDoc);

  util.matchStandardRequestHeaders(wstrustRequest);

  return wstrustRequest;
};
开发者ID:AzureAD,项目名称:azure-activedirectory-library-for-nodejs,代码行数:11,代码来源:util.ts

示例7: it

 it('sould call callback with value', done => {
   const endpoint = 'tag/sunset';
   nock('https://api.instagram.com')
     .get(`/v1/${endpoint}`)
     .query({ access_token: 'toto' })
     .reply(200, { message: 'success' });
   (instagram as any).request('GET', endpoint, (_, result) => {
     expect(result).toMatchSnapshot();
     done();
   });
 });
开发者ID:pradel,项目名称:node-instagram,代码行数:11,代码来源:index.ts

示例8: async

 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:perryao,项目名称:google-api-nodejs-client,代码行数:11,代码来源:test.media.ts

示例9: it

    it('should set loading status as expected', function () {
      const scope = nock(BASE_URL).get('/api/settings').reply(200);
      const promise = store.load()
        .then(() => {
          scope.done();
          expect(store.loading).to.be.false;
        });

      expect(store.loading).to.be.true;
      return promise;
    });
开发者ID:Xristinaaaa,项目名称:Telerik2016,代码行数:11,代码来源:SettingsStore-spec.ts


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