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


TypeScript Sinon.useFakeTimers函数代码示例

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


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

示例1: beforeEach

    beforeEach(() => {
        clock = sinon.useFakeTimers();
        // Pretend we are a browser
        global['navigator'] = {
            hardwareConcurrency: 8,
            oscpu: 'Win32',
            language: 'en-GB',
            userAgent: 'foo',
            platform: 'Win32'
        };

        global['screen'] = {
            width: 1024,
            height: 1024,
            colorDepth: 32,
            orientation: {
                type: 'landscape-primary'
            }
        };

        global['window'] = {
            outerWidth: 1000,
            outerHeight: 1000,
            innerWidth: 950,
            innerHeight: 950
        };
        
        subject = new UserEnvironment();

    });
开发者ID:LiberisLabs,项目名称:raygun-angular2,代码行数:30,代码来源:UserEnvironment.ts

示例2: test

    test('build range filter in iso format', () => {
      const clock = sinon.useFakeTimers(moment.utc([2000, 1, 1, 0, 0, 0, 0]).valueOf());

      const filter = getTime(
        {
          id: 'test',
          title: 'test',
          timeFieldName: 'date',
          fields: [
            {
              name: 'date',
              type: 'date',
              esTypes: ['date'],
              aggregatable: true,
              searchable: true,
              filterable: true,
            },
          ],
        },
        { from: 'now-60y', to: 'now' }
      ) as Filter;
      expect(filter.range.date).to.eql({
        gte: '1940-02-01T00:00:00.000Z',
        lte: '2000-02-01T00:00:00.000Z',
        format: 'strict_date_optional_time',
      });
      clock.restore();
    });
开发者ID:elastic,项目名称:kibana,代码行数:28,代码来源:get_time.test.ts

示例3: it

 it('should use current time if not passed', () => {
   const fakeTimers = sinon.useFakeTimers();
   fakeTimers.setSystemTime(112233 * 1000);
   inst.lastReceipt.update();
   expect(inst.lastReceipt.get()).to.be.eq(112233);
   fakeTimers.restore();
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:7,代码来源:blocks.spec.ts

示例4: function

    function () {
      const clock = sinon.useFakeTimers();

      const autoReload = true;
      const updatePreset = sinon.stub().returns(Promise.resolve());
      const applyCustomization = sinon.spy();
      const reload = sinon.spy();
      const cancel = sinon.stub();
      const showCustomizationMessage = sinon.spy();

      return applyDetection('', '', undefined, undefined, undefined, autoReload,
        updatePreset, applyCustomization, reload, cancel, showCustomizationMessage)
        .then(() => {
          // No functions should have been called before 1s
          clock.tick(999);
          expect(applyCustomization.called).to.be.false;
          expect(reload.called).to.be.false;
          expect(showCustomizationMessage.called).to.be.false;

          // Only 'applyCustomization' and 'reload' functions should have been called on 1s
          clock.tick(1);
          expect(applyCustomization.called).to.be.true;
          expect(reload.called).to.be.true;
          expect(showCustomizationMessage.called).to.be.false;

          clock.restore();
        });
    });
开发者ID:yomed,项目名称:vscode-icons,代码行数:28,代码来源:autoDetectProject.test.ts

示例5: test

    test('failed RPC call', function (done) {
      var clock = sinon.useFakeTimers()

      var daemon = new stratum.Daemon({
        path: '/doesnt/exist/%s',
        datadir: 'data/dir',
        port: 8080,
        host: 'localhost',
        user: 'user',
        password: 'pass',
        name: 'Mycoin'
      })

      sinon.stub(daemon.rpc, 'call').callsFake(function (name, params, callback) {
        if (name === 'test') {
          callback('error')
        }
      })

      daemon.call('test').catch(function (message) {
        expect(message).to.equal('error')
      }).done(function () {
        var promise = daemon.call('timeout')
        clock.tick(4000)

        promise.catch(function (message) {
          expect(message).to.be('Command timed out')
        }).done(function () {
          clock.restore()
          done()
        })
      })

    })
开发者ID:pocesar,项目名称:node-stratum,代码行数:34,代码来源:tests.ts

示例6: it

    it('can temporarily be disabled with ssrForceFetchDelay', () => {
      clock = sinon.useFakeTimers();

      const client = new ApolloClient({
        networkInterface,
        ssrForceFetchDelay: 100,
        addTypename: false,
      });

      // Run a query first to initialize the store
      const outerPromise = client.query({ query })
        // then query for real
        .then(() => {
          const promise = client.query({ query, forceFetch: true });
          clock.tick(0);
          return promise;
        })
        .then((result) => {
          assert.deepEqual(result.data, { myNumber: { n: 1 } });
          clock.tick(100);
          const promise = client.query({ query, forceFetch: true });
          clock.tick(0);
          return promise;
        })
        .then((result) => {
          assert.deepEqual(result.data, { myNumber: { n: 2 } });
        });
      clock.tick(0);
      return outerPromise;
    });
开发者ID:drager,项目名称:apollo-client,代码行数:30,代码来源:client.ts

示例7: beforeEach

 beforeEach(async () => {
     await blockchainLifecycle.startAsync();
     const sinonTimerConfig = { shouldAdvanceTime: true } as any;
     // This constructor has incorrect types
     timer = Sinon.useFakeTimers(sinonTimerConfig);
     currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
     expirationWatcher = new ExpirationWatcher();
 });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:8,代码来源:expiration_watcher_test.ts

示例8: it

    it('should calculate `nextRunAt` with `interval`', () => {
        const clock = sinon.useFakeTimers(new Date('2016-07-05 22:02:50').getTime());

        return instance.every((1000 * 60 * 5), 'task5', {qwe: 'asd'}).then((createdTask) => {
            createdTask.nextRunAt.getTime().should.be.equal(new Date('2016-07-05 22:07:50').getTime());
            clock.restore();
        });
    });
开发者ID:CodeZavod,项目名称:scheduler,代码行数:8,代码来源:index.ts


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