本文整理匯總了TypeScript中Sinon.SinonStub.throws方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript SinonStub.throws方法的具體用法?TypeScript SinonStub.throws怎麽用?TypeScript SinonStub.throws使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sinon.SinonStub
的用法示例。
在下文中一共展示了SinonStub.throws方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should throw and remove peer if parseRequest throws', async () => {
const err = new Error('pr err');
parseRequestStub.throws(err);
await expect(instance.postBlock(req)).to.be.rejectedWith(err);
expect(peersModuleStub.stubs.remove.calledOnce).to.be.true;
expect(peersModuleStub.stubs.remove.firstCall.args)
.to.be.deep.equal([req.ip, parseInt(req.headers.port as string, 10)]);
});
示例2: it
it('should call logger.warn in scheduled job if this.forge throws', async () => {
const expectedError = new Error('err');
forgeStub.throws(expectedError);
const p = inst.onBlockchainReady();
clock.tick(500000);
await p;
expect(loggerStub.stubs.warn.calledOnce).to.be.true;
expect(loggerStub.stubs.warn.firstCall.args[0]).to.be.equal('Error in nextForge');
expect(loggerStub.stubs.warn.firstCall.args[1]).to.be.deep.equal(expectedError);
});