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

TypeScript nock.enableNetConnect函数代码示例

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

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



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

示例1: it

 it('should allow default params to be overriden per-request', async () => {
   const google = new GoogleApis();
   const datastore =
       google.datastore({version: 'v1', params: {myParam: '123'}});
   // Override the default datasetId param for this particular API call
   createNock('myParam=456');
   const res = await datastore.projects.lookup(
       // tslint:disable-next-line no-any
       {projectId: 'test-project-id', myParam: '456'} as any);
   // If the default param handling is broken, query might be undefined, thus
   // concealing the assertion message with some generic "cannot call .indexOf
   // of undefined"
   const query = Utils.getQs(res) || '';
   assert.notEqual(
       query.indexOf('myParam=456'), -1, 'Default param not found in query');
   nock.enableNetConnect();
   const datastore2 = await Utils.loadApi(
       google, 'datastore', 'v1', {params: {myParam: '123'}});
   nock.disableNetConnect();
   // Override the default datasetId param for this particular API call
   createNock('myParam=456');
   // tslint:disable-next-line no-any
   const res2 = await (datastore2 as any).projects.lookup({
     projectId: 'test-project-id',
     myParam: '456'
   });
   // If the default param handling is broken, query might be undefined,
   // thus concealing the assertion message with some generic "cannot
   // call .indexOf of undefined"
   const query2 = Utils.getQs(res2) || '';
   assert.notEqual(
       query2.indexOf('myParam=456'), -1, 'Default param not found in query');
 });
开发者ID:dmytrobanasko,项目名称:google-api-nodejs-client,代码行数:33,代码来源:test.clients.ts


示例2: before

 before(async () => {
   nock.cleanAll();
   const google = new GoogleApis();
   nock.enableNetConnect();
   remoteDrive = await Utils.loadApi(google, 'drive', 'v2');
   nock.disableNetConnect();
 });
开发者ID:dmytrobanasko,项目名称:google-api-nodejs-client,代码行数:7,代码来源:test.drive.v2.ts


示例3: before

 before(async () => {
   nock.cleanAll();
   const google = new GoogleApis();
   nock.enableNetConnect();
   remoteUrlshortener = await Utils.loadApi<urlshortener_v1.Urlshortener>(
       google, 'urlshortener', 'v1');
   nock.disableNetConnect();
 });
开发者ID:dmytrobanasko,项目名称:google-api-nodejs-client,代码行数:8,代码来源:test.urlshortener.v1.ts


示例4: test

 test('create-from-url-network-error', function (done) {
   nock.enableNetConnect();
   adal.createAuthenticationParametersFromUrl('https://0.0.0.0/test', function (err) {
     assert(err, 'Did not receive expected error');
     nock.disableNetConnect();
     done();
   });
 });
开发者ID:AzureAD,项目名称:azure-activedirectory-library-for-nodejs,代码行数:8,代码来源:authentication-parameters.ts


示例5: before

 before(async () => {
   nock.cleanAll();
   const google = new GoogleApis();
   nock.enableNetConnect();
   [remotePlus, remoteOauth2] = await Promise.all([
     Utils.loadApi(google, 'plus', 'v1'), Utils.loadApi(google, 'oauth2', 'v2')
   ]);
   nock.disableNetConnect();
 });
开发者ID:sgaluza,项目名称:google-api-nodejs-client,代码行数:9,代码来源:test.clients.ts


示例6: before

 before(async () => {
   nock.cleanAll();
   const google = new GoogleApis();
   nock.enableNetConnect();
   [remoteDrive, remoteGmail] = await Promise.all([
     Utils.loadApi(google, 'drive', 'v2'), Utils.loadApi(google, 'gmail', 'v1')
   ]);
   nock.disableNetConnect();
 });
开发者ID:sgaluza,项目名称:google-api-nodejs-client,代码行数:9,代码来源:test.media.ts


示例7: before

 before(async () => {
   nock.cleanAll();
   const google = new GoogleApis();
   nock.enableNetConnect();
   [remoteDrive, remoteOauth2, remoteUrlshortener] = await Promise.all([
     Utils.loadApi(google, 'drive', 'v2'),
     Utils.loadApi(google, 'oauth2', 'v2'),
     Utils.loadApi(google, 'urlshortener', 'v1'),
   ]);
   nock.disableNetConnect();
 });
开发者ID:google,项目名称:google-api-nodejs-client,代码行数:11,代码来源:test.transporters.ts


示例8: test

  test('failed-http-request', function (done) {
    this.timeout(6000);
    this.slow(4000);  // This test takes longer than I would like to fail.  It probably needs a better way of producing this error.

    nock.enableNetConnect();
    var context = new AuthenticationContext('https://0.1.1.1:12/my.tenant.com');
    context.acquireTokenWithAuthorizationCode(authorizationCode, redirectUri, cp.resource, cp.clientId, cp.clientSecret, function (err) {
      assert(err, 'Did not receive expected error on failed http request.');
      nock.disableNetConnect();
      done();
    });
  });
开发者ID:AzureAD,项目名称:azure-activedirectory-library-for-nodejs,代码行数:12,代码来源:authorization-code.ts


示例9: test

  test('failed-http-request', function (done) {
    this.timeout(6000);
    this.slow(4000);

    nock.enableNetConnect();
    var context = new AuthenticationContext('https://0.0.0.0:11/my.test.tenant.com');
    context.acquireUserCode(cp.resource, cp.clientId, cp.language, function (err) {
      assert(err, 'Did not recieve expected error on failed http request.');
      nock.disableNetConnect();
      done();
    });
  });
开发者ID:AzureAD,项目名称:azure-activedirectory-library-for-nodejs,代码行数:12,代码来源:acquire-user-code.ts


示例10: it

  it('should include default params when only callback is provided to API call', async () => {
    const google = new GoogleApis();
    const datastore = google.datastore({
      version: 'v1',
      params: {
        // We must set this here - it is a required param
        projectId: 'test-project-id',
        myParam: '123',
      },
    });
    // No params given - only callback
    createNock('myParam=123');
    const res = await datastore.projects.lookup();
    // If the default param handling is broken, req or query might be
    // undefined, thus concealing the assertion message with some generic
    // "cannot call .indexOf of undefined"
    const query = Utils.getQs(res) || '';

    assert.notStrictEqual(
      query.indexOf('myParam=123'),
      -1,
      'Default param not found in query'
    );

    nock.enableNetConnect();
    const datastore2 = await Utils.loadApi(google, 'datastore', 'v1', {
      params: {
        projectId: 'test-project-id', // We must set this here - it is a
        // required param
        myParam: '123',
      },
    });

    nock.disableNetConnect();

    // No params given - only callback
    createNock('myParam=123');
    // tslint:disable-next-line no-any
    const res3 = await (datastore2 as any).projects.lookup();
    // If the default param handling is broken, req or query might be
    // undefined, thus concealing the assertion message with some
    // generic "cannot call .indexOf of undefined"
    const query2 = Utils.getQs(res3) || '';
    assert.notStrictEqual(
      query2.indexOf('myParam=123'),
      -1,
      'Default param not found in query'
    );
  });
开发者ID:google,项目名称:google-api-nodejs-client,代码行数:49,代码来源:test.clients.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript nock.isDone函数代码示例发布时间:2022-05-25
下一篇:
TypeScript nock.disableNetConnect函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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