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


TypeScript lolex.install函數代碼示例

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


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

示例1: it

    it('should ignore bank holiday to compute the next date', () => {
      const clock = lolex.install({ now: new Date('2017-08-14T16:00') });
      const nextRunAt = Routine.computeNextRunAt('0 12 * * *', true);
      clock.uninstall();

      expect(nextRunAt).toEqual(new Date('2017-08-15T12:00'));
    });
開發者ID:7h1b0,項目名稱:Anna,代碼行數:7,代碼來源:routine.test.ts

示例2: it

    it('should load and start every routine', async () => {
      const clock = lolex.install();
      await routineService.load();
      clock.uninstall();

      expect(clock.countTimers()).toBe(2);
    });
開發者ID:7h1b0,項目名稱:Anna,代碼行數:7,代碼來源:routineService.test.ts

示例3: it

    it('should resolve with the cached token if there is a valid one', () => {

      // given
      const clock = lolex.install();
      const initialLifetime = 3600;
      const timeBeforeExpiry = initialLifetime * (1 - defaultCacheConfig.percentageLeft) * 1000 - 1;

      nock(oauthHost)
        .post('/access_token')
        .reply(HttpStatus.OK, {
          access_token: defaultAccessTokenValue,
          expires_in: initialLifetime
        })
        .get('/tokeninfo')
        .query({ access_token: defaultAccessTokenValue })
        .reply(HttpStatus.OK, defaultTokenInfoResponse);

      // when
      const tokenService = new TokenCache({
        'nucleus': ['nucleus.write', 'nucleus.read'],
        'halo': ['all']
      }, oauthConfig);

      const promise = tokenService.get('nucleus')
        .then(() => clock.tick(timeBeforeExpiry))
        .then(() => tokenService.get('nucleus'))
        .then((token) => {
          clock.uninstall();
          return token.access_token;
        });

      // then
      return expect(promise).to.become(defaultAccessTokenValue);
    });
開發者ID:zalando-incubator,項目名稱:lib-oauth-tooling,代碼行數:34,代碼來源:tokenCache.spec.ts

示例4: it

      it('should enable routine and compute nextRunAt', async () => {
        const clock = lolex.install({ now: new Date('2017-08-12T16:00:00') });

        const response = await request(app)
          .patch(`/api/routines/${initRoutines[2].routineId}`)
          .set('Accept', 'application/json')
          .set('x-access-token', user.token)
          .send({
            sceneId: 'faaed78e-fd1c-4717-b610-65d2fa3d01b2',
            name: 'routine_updated',
            interval: '0 12 * * *',
            enabled: true,
          });

        expect(response.status).toHaveStatusOk();
        expect(clock.countTimers()).toBe(1);

        const routine = await knex(Routine.TABLE)
          .first()
          .where('routineId', initRoutines[2].routineId);

        expect(routine.nextRunAt).toEqual(
          new Date('2017-08-13T12:00:00').getTime(),
        );
        expect(routine).toMatchSnapshot({
          createdAt: expect.any(Number),
          updatedAt: expect.any(Number),
          nextRunAt: expect.any(Number),
        });

        clock.uninstall();
      });
開發者ID:7h1b0,項目名稱:Anna,代碼行數:32,代碼來源:routine.test.ts

示例5: TestMongo

test.beforeEach(async t => {
    const testmongo = new TestMongo()
    const db = await testmongo.getDb()

    t.log(`Database ${testmongo.getUrl()} created`)
    t.context = {
        ms: new DBMediaService(LoggerMock('test'), {
            dbUrl: testmongo.getUrl(),
        }),
        mongo: testmongo,
        clock: lolex.install(),
    }
    await t.context.ms.connect()
})
開發者ID:ha4us,項目名稱:ha4us.old,代碼行數:14,代碼來源:db-media.service.spec.ts


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