當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。