本文整理匯總了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') },
};
};
});