本文整理汇总了TypeScript中Sinon.SinonStub.rejects方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonStub.rejects方法的具体用法?TypeScript SinonStub.rejects怎么用?TypeScript SinonStub.rejects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.SinonStub
的用法示例。
在下文中一共展示了SinonStub.rejects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should call logger.error if db query was throw error', async () => {
const error = new Error('errors');
findAllStub.rejects(error);
await instR.onBlockchainReady();
expect(loggerStub.stubs.error.calledOnce).to.be.true;
expect(loggerStub.stubs.error.firstCall.args.length).to.be.equal(2);
expect(loggerStub.stubs.error.firstCall.args[0]).to.be.equal('Import peers from database failed');
expect(loggerStub.stubs.error.firstCall.args[1]).to.be.deep.equal({error: error.message});
});
示例2: it
it('with fields; should propagate it', async () => {
const error = 'error';
const fields: FieldsInModel<AccountsModel> = ['username'];
getAllStub.rejects(new Error(error));
await expect(account.get(filter, fields)).to.be.rejectedWith('error');
expect(getAllStub.calledOnce).is.true;
expect(getAllStub.firstCall.args[0]).to.be.deep.eq(filter);
expect(getAllStub.firstCall.args[1]).to.be.deep.eq(fields);
});
示例3: it
it('should call logger.debug on fail', async () => {
const error = new Error('error');
broadcastStub.rejects(error);
await (instance as any).releaseQueue();
expect(loggerStub.stubs.warn.calledOnce).to.be.true;
expect(loggerStub.stubs.warn.firstCall.args.length).to.be.equal(2);
expect(loggerStub.stubs.warn.firstCall.args[0]).to.be.equal('Failed to release broadcast queue');
expect(loggerStub.stubs.warn.firstCall.args[1]).to.be.equal(error);
});
示例4: it
it('should call queueTransaction if bundled is true', async () => {
// we make processVerifyTransaction reject in order to stop execution before next call of queueTransaction
processVerifyTransactionStub.rejects();
const queueTransactionSpy = sandbox.spy(instance, 'queueTransaction');
await instance.processNewTransaction(tx, false);
expect(queueTransactionSpy.calledOnce).to.be.true;
expect(queueTransactionSpy.firstCall.args[0]).to.be.deep.equal(tx);
expect(queueTransactionSpy.firstCall.args[1]).to.be.true;
});
示例5: it
it('should call logger.debug if receiveSignature throw error', async () => {
const error = new Error('error');
receiveSignatureStub.rejects(error);
await inst.receiveSignatures(query);
expect(logger.stubs.debug.calledOnce).to.be.true;
expect(logger.stubs.debug.firstCall.args.length).to.be.equal(2);
expect(logger.stubs.debug.firstCall.args[0]).to.be.equal(error);
expect(logger.stubs.debug.firstCall.args[1]).to.be.deep.equal(query[0]);
});
示例6: it
it('should set isTicking to true and then false if error', async () => {
txGeneratorStub.rejects(new Error('error'));
await expect((instance as any).innerTick(block, 'tx', true, txGeneratorStub, afterTxPromiseStub))
.rejectedWith('error');
expect(appStateStub.stubs.set.callCount).is.eq(2);
expect(appStateStub.stubs.set.firstCall.args[0]).is.eq('rounds.isTicking');
expect(appStateStub.stubs.set.firstCall.args[1]).is.eq(true);
expect(appStateStub.stubs.set.secondCall.args[0]).is.eq('rounds.isTicking');
expect(appStateStub.stubs.set.secondCall.args[1]).is.eq(false);
});
示例7: it
it('Failed to get transactions', async () => {
findAndCountAllStub.rejects(new Error('Failed to get transactions'));
const body = {
blockId : '100',
fromHeight : '123',
recipientIds : 'd,e,f',
recipientPublicKeys: 'j,k,l',
senderPublicKeys : 'g,h,i',
};
await expect(instance.getTransactions(body)).to.be.rejectedWith(
'Failed to get transactions'
);
});