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