• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript nock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript node-fetch类代码示例发布时间:2022-05-28
下一篇:
TypeScript next类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap