本文整理汇总了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);
});