当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript SinonStub.rejects方法代码示例

本文整理汇总了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});
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:9,代码来源:peers.spec.ts

示例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);
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:9,代码来源:account.spec.ts

示例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);
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:9,代码来源:broadcaster.spec.ts

示例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;
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:9,代码来源:transactionPool.spec.ts

示例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]);
    });
开发者ID:RiseVision,项目名称:rise-node,代码行数:11,代码来源:transport.spec.ts

示例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);
    });
开发者ID:RiseVision,项目名称:rise-node,代码行数:12,代码来源:rounds.spec.ts

示例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'
   );
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:13,代码来源:transactions.spec.ts


注:本文中的Sinon.SinonStub.rejects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。