當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript nock.cleanAll函數代碼示例

本文整理匯總了TypeScript中nock.cleanAll函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript cleanAll函數的具體用法?TypeScript cleanAll怎麽用?TypeScript cleanAll使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了cleanAll函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('should support global request params', async () => {
   const google = new GoogleApis();
   google.options({params: {myParam: '123'}});
   const drive = google.drive('v2');
   nock(Utils.baseUrl).get('/drive/v2/files/123?myParam=123').reply(200);
   const res = await drive.files.get({fileId: '123'});
   // If the default param handling is broken, query might be undefined, thus
   // concealing the assertion message with some generic "cannot call
   // .indexOf of undefined"
   let query = Utils.getQs(res) || '';
   assert.notEqual(
       query.indexOf('myParam=123'), -1, 'Default param not found in query');
   // I can't explain why, but the `nock.enableNetConnect()` call below simply
   // won't work unless I call `nock.cleanAll()` first.
   nock.cleanAll();
   nock.enableNetConnect();
   const d = await Utils.loadApi(google, 'drive', 'v2');
   nock.disableNetConnect();
   nock(Utils.baseUrl).get('/drive/v2/files/123?myParam=123').reply(200);
   // tslint:disable-next-line no-any
   const res3 = await (d as any).files.get({fileId: '123'});
   // If the default param handling is broken, query might be undefined,
   // thus concealing the assertion message with some generic "cannot
   // call .indexOf of undefined"
   query = Utils.getQs(res3) || '';
   assert.notEqual(
       query.indexOf('myParam=123'), -1, 'Default param not found in query');
 });
開發者ID:sheerun,項目名稱:google-api-nodejs-client,代碼行數:28,代碼來源:test.options.ts

示例2: beforeEach

 beforeEach(() => {
   nock.cleanAll();
   nock.disableNetConnect();
   const google = new GoogleApis();
   localPlus = google.plus('v1');
   localOauth2 = google.oauth2('v2');
 });
開發者ID:google,項目名稱:google-api-nodejs-client,代碼行數:7,代碼來源:test.clients.ts

示例3: beforeEach

 beforeEach(() => {
   nock.cleanAll();
   nock.disableNetConnect();
   const google = new GoogleApis();
   localDrive = google.drive('v2');
   localUrlshortener = google.urlshortener('v1');
 });
開發者ID:dmytrobanasko,項目名稱:google-api-nodejs-client,代碼行數:7,代碼來源:test.auth.ts

示例4: 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.path.ts

示例5: beforeEach

 beforeEach(() => {
   nock.cleanAll();
   nock.disableNetConnect();
   const google = new GoogleApis();
   localDrive = google.drive('v2');
   localGmail = google.gmail('v1');
 });
開發者ID:dmytrobanasko,項目名稱:google-api-nodejs-client,代碼行數:7,代碼來源:test.media.ts

示例6: afterEach

 afterEach(() => {
   if (!nock.isDone()) {
     // tslint:disable-next-line
     console.error('nock is not done', nock.pendingMocks());
   }
   nock.cleanAll();
 });
開發者ID:wix,項目名稱:media-platform-js-sdk,代碼行數:7,代碼來源:job-manager.spec.ts

示例7: before

 before(async () => {
   nock.cleanAll();
   const google = new GoogleApis();
   nock.enableNetConnect();
   remoteUrlshortener = await Utils.loadApi(google, 'urlshortener', 'v1');
   nock.disableNetConnect();
 });
開發者ID:sgaluza,項目名稱:google-api-nodejs-client,代碼行數:7,代碼來源:test.urlshortener.v1.ts

示例8: afterEach

 afterEach(() => {
   sandbox.verifyAndRestore();
   if (!nock.isDone()) {
     // tslint:disable-next-line
     console.error('nock is not done', nock.pendingMocks());
   }
   nock.cleanAll();
 });
開發者ID:wix,項目名稱:media-platform-js-sdk,代碼行數:8,代碼來源:http-client.spec.ts

示例9: afterEach

 afterEach(function (done) {
     process.env.SKIP_STATISTICS = "true";
     nock.cleanAll();
     if (!nock.isActive()) {
         nock.activate();
     }
     done();
 });
開發者ID:bespoken,項目名稱:bst,代碼行數:8,代碼來源:bst-statistics-test.ts

示例10: it

  it('should redirect to access denied page when user not in required role', async () => {
    mock.cleanAll()
    idamServiceMock.resolveRetrieveUserFor('1', 'divorce-private-beta')

    await request.agent(app)[method](pagePath)
      .set('Cookie', `${cookieName}=ABC`)
      .expect(res => expect(res).redirect.toLocation(accessDeniedPage))
  })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:8,代碼來源:authorization-check.ts


注:本文中的nock.cleanAll函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。