當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。