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


TypeScript SinonStub.resolves方法代码示例

本文整理汇总了TypeScript中Sinon.SinonStub.resolves方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonStub.resolves方法的具体用法?TypeScript SinonStub.resolves怎么用?TypeScript SinonStub.resolves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sinon.SinonStub的用法示例。


在下文中一共展示了SinonStub.resolves方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

    it('should call accountLogic.merge if objectNormalize resolves', async () => {
      objectNormalizeStub.resolves();
      const ops = await instance.undoUnconfirmed(tx, sender);
      expect(ops.length).eq(2);
      const first: DBRemoveOp<any> = ops[0] as any;
      const second: DBBulkCreateOp<any> = ops[1] as any;

      expect({ ... first, model: first.model.getTableName()}).deep.eq({
        type: 'remove',
        model: Accounts2U_DelegatesModel.getTableName(),
        options: {
          limit: 1,
          where: {
            accountId: tx.senderId,
            dependentId: [
              '05a37e6c6588716f9c9a2bac4bac0a1525e9605abac4153016f95a37e6c6588a'
            ],
          },
        },
      });

      expect({ ... second, model: second.model.getTableName()}).deep.eq({
        type: 'bulkCreate',
        model: Accounts2U_DelegatesModel.getTableName(),
        values: [
          {
            dependentId: '7e58fe36588716f9c941530c74eabdf0b27b1a2bac0a1525e9605a37e6c0b381',
            accountId: tx.senderId,
          },
        ],
      });
    });
开发者ID:RiseVision,项目名称:rise-node,代码行数:32,代码来源:vote.spec.ts

示例2: it

    it('should use model result and modify original arr', async () => {
      modelFindAllStub.resolves([
        { transactionId: 2, min: 90, lifetime: 33, keysgroup: '+dd,+ee,+ff'},
        { transactionId: 1, min: 10, lifetime: 30, keysgroup: '+aa,+bb,+cc'},
      ]);
      const txs: any = [{id: 1}, {id: 2}];

      await instance.attachAssets(txs);

      expect(txs[0]).deep.eq({
        id: 1, asset: {
          multisignature: {
            min      : 10, lifetime: 30,
            keysgroup: ['+aa', '+bb', '+cc'],
          },
        },
      });
      expect(txs[1]).deep.eq({
        id: 2, asset: {
          multisignature: {
            min      : 90, lifetime: 33,
            keysgroup: ['+dd', '+ee', '+ff'],
          },
        },
      });
    });
开发者ID:RiseVision,项目名称:rise-node,代码行数:26,代码来源:createmultisig.spec.ts

示例3: it

 it('should return at least 1 block', async () => {
   blockLogicStub.stubs.getMinBytesSize.returns(2000000);
   findAllTxsStub.resolves([{type: 0, height: 123457}]);
   await instance.getBlocks('123');
   const lastHeight = blocksSubmoduleUtilsStub.stubs.loadBlocksData.firstCall.args[0].limit;
   expect(lastHeight).eq(1);
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:7,代码来源:transportV2API.spec.ts

示例4: it

 it('should throw if block already exists in db', async () => {
   sinon.stub(inst, 'verifyBlock').resolves(Promise.resolve({ errors  : [], verified: true }));
   blockLogic.enqueueResponse('objectNormalize', {id: '1', normalized: 'block'});
   findByIdStub.resolves({})
   await expect(inst.processBlock(null, true, true))
     .to.be.rejectedWith('Block 1 already exists');
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:7,代码来源:verify.spec.ts

示例5: it

 it('should call applyGenesisBlock if blockid is same as genesis', async () => {
   const genesis: SignedAndChainedBlockType = container.get(Symbols.generic.genesisBlock);
   blocksUtils.reset();
   blocksModelFindAllStub.resolves([genesis]);
   blocksChain.enqueueResponse('applyGenesisBlock', Promise.resolve());
   await inst.loadBlocksOffset(10, 0, false);
   expect(blocksChain.stubs.applyGenesisBlock.calledOnce).is.true;
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:8,代码来源:process.spec.ts

示例6: it

 it('should call saveBlock and pass tx if genesis does not exist', async () => {
   findByIdStub.resolves(null);
   await inst.saveGenesisBlock();
   expect(txStub.called).is.true;
   expect(saveBlockStub.called).is.true;
   expect(txStub.calledBefore(saveBlockStub)).is.true;
   expect(saveBlockStub.firstCall.args[1]).is.eq('tx');
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:8,代码来源:chain.spec.ts

示例7: it

 it('should call logger.debug and return if getBlockSlotData returns null', async () => {
   getBlockSlotDataStub.resolves(null);
   await instance.forge();
   expect(loggerStub.stubs.debug.calledOnce).to.be.true;
   expect(loggerStub.stubs.debug.firstCall.args[0]).to.be.equal('Skipping delegate slot');
   // Called twice means that function returns
   expect(slotsStub.stubs.getSlotNumber.calledTwice).to.be.true;
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:8,代码来源:forge.spec.ts

示例8: it

 it('should setAccountAndGet if nopublickey set in db and throw if address does not match', async () => {
   findAllStub.resolves([{address: 'add11'}]);
   await expect(accountModule.resolveAccountsForTransactions([
     {senderId: 'add11', senderPublicKey: Buffer.from('22', 'hex')} as any
   ])).rejectedWith('Stealing attempt type.1 for add11');
   expect(setAccountAndGetStub.called).is.true;
   expect(setAccountAndGetStub.firstCall.args[0])
     .is.deep.eq({publicKey: Buffer.from('22', 'hex')});
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:9,代码来源:accounts.spec.ts


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