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


TypeScript SinonSandbox.useFakeTimers方法代码示例

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


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

示例1: beforeEach

  beforeEach(() => {
    sandbox    = sinon.createSandbox();
    container = createContainer();
    clock      = sandbox.useFakeTimers();
    fakeConfig = { forging: { secret: ['secret1', 'secret2'] } };

    jobsQueueStub           = container.get(Symbols.helpers.jobsQueue);
    loggerStub              = container.get(Symbols.helpers.logger);
    edStub                  = container.get(Symbols.helpers.ed);
    slotsStub               = container.get(Symbols.helpers.slots);
    appStateStub            = container.get(Symbols.logic.appState);
    broadcasterLogicStub    = container.get(Symbols.logic.broadcaster);
    accountsModuleStub      = container.get(Symbols.modules.accounts);
    blocksModuleStub        = container.get(Symbols.modules.blocks);
    delegatesModuleStub     = container.get(Symbols.modules.delegates);
    transactionsModuleStub  = container.get(Symbols.modules.transactions);
    blocksProcessModuleStub = container.get(Symbols.modules.blocksSubModules.process);
    sequenceStub            = {
      addAndPromise: sandbox.spy((w) => {
        return Promise.resolve(
          w()
        );
      }),
    };

    instance = new ForgeModule();
    instance = instance as any;

    instance.enabledKeys         = {};
    instance.config              = fakeConfig;
    instance.constants           = constants;
    instance.jobsQueue           = jobsQueueStub;
    instance.logger              = loggerStub;
    instance.ed                  = edStub;
    instance.defaultSequence     = sequenceStub;
    instance.slots               = slotsStub;
    instance.appState            = appStateStub;
    instance.broadcasterLogic    = broadcasterLogicStub;
    instance.accountsModule      = accountsModuleStub;
    instance.blocksModule        = blocksModuleStub;
    instance.delegatesModule     = delegatesModuleStub;
    instance.transactionsModule  = transactionsModuleStub;
    instance.blocksProcessModule = blocksProcessModuleStub;

    sha256Spy              = sandbox.spy(supersha, 'sha256');
    blocksModuleStub.lastBlock = BlocksModel.classFromPOJO({
      blockSignature      : Buffer.from('blockSignature'),
      generatorPublicKey  : Buffer.from('pubKey'),
      height              : 12422,
      id                  : 'blockID',
      numberOfTransactions: 0,
      payloadHash         : Buffer.from('payload'),
      payloadLength       : 0,
      previousBlock       : 'previous',
      reward              : 15,
      timestamp           : Date.now(),
      totalAmount         : 0,
      totalFee            : 0,
      version             : 1,
    });
    loadKeypairs               = () => {
      instance.enabledKeys = {
        aaaa: true,
        bbbb: true,
        cccc: true,
      };
      instance.keypairs    = {
        aaaa: { publicKey: Buffer.from('aaaa', 'hex') },
        bbbb: { publicKey: Buffer.from('bbbb', 'hex') },
        cccc: { publicKey: Buffer.from('cccc', 'hex') },
      };
    };
  });
开发者ID:RiseVision,项目名称:rise-node,代码行数:73,代码来源:forge.spec.ts


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