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


TypeScript SinonSandbox.spy方法代码示例

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


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

示例1: beforeEach

 beforeEach(() => {
   sandbox = sinon.createSandbox();
   logFileFake = {};
   logFileFake.write = () => true;
   logFileWriteSpy = sandbox.spy(logFileFake, 'write');
   fsStub = sandbox.stub(fs, 'createWriteStream').returns(logFileFake);
   consoleLogSpy = sandbox.spy(console, 'log');
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:8,代码来源:logger.spec.ts

示例2: it

 it('should call String.toLowercase.trim', async () => {
   const toLowercaseSpy = sandbox.spy(String.prototype, 'toLowerCase');
   const trimSpy        = sandbox.spy(String.prototype, 'trim');
   await instance.verify(tx, sender);
   expect(toLowercaseSpy.calledTwice).to.be.true;
   expect(trimSpy.calledOnce).to.be.true;
   toLowercaseSpy.restore();
   trimSpy.restore();
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:9,代码来源:delegate.spec.ts

示例3: beforeEach

 beforeEach(() => {
   container = createContainer();
   container.bind(Symbols.api.utils.attachPeerHeaderToResponseObject).to(AttachPeerHeaders);
   sandbox = sinon.createSandbox();
   response = {set: () => true};
   responseSpy = sandbox.spy(response, 'set');
   request = {};
   next = sandbox.spy();
   instance = container.get(Symbols.api.utils.attachPeerHeaderToResponseObject);
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:10,代码来源:attachPeerHeaders.spec.ts

示例4: it

 it('should call firstInRound and lastInRound', () => {
   const firstInRoundSpy = sandbox.spy(instance, 'firstInRound');
   const lastInRoundSpy  = sandbox.spy(instance, 'lastInRound');
   instance.heightFromRound(round);
   expect(firstInRoundSpy.calledOnce).to.be.true;
   expect(lastInRoundSpy.calledOnce).to.be.true;
   expect(firstInRoundSpy.firstCall.args[0]).to.be.equal(round);
   expect(lastInRoundSpy.firstCall.args[0]).to.be.equal(round);
   firstInRoundSpy.restore();
   lastInRoundSpy.restore();
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:11,代码来源:rounds.spec.ts

示例5: beforeEach

 beforeEach(() => {
   sandbox = sinon.createSandbox();
   loggerFake = { log: () => true };
   loggerSpy = sandbox.spy(loggerFake, 'log');
   req = { method: 'aaa', url: 'bbb', ip: '80.3.10.20' };
   sendObject = { send: () => () => true };
   sendSpy = sandbox.spy(sendObject, 'send');
   res = { setHeader: () => true, status: () => sendObject };
   setHeaderSpy = sandbox.spy(res, 'setHeader');
   statusSpy = sandbox.spy(res, 'status');
   next = sandbox.stub().returns(123);
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:12,代码来源:httpApi.spec.ts

示例6: constructor

  constructor() {
    const orig       = new BlocksModule();
    this.lastReceipt = orig.lastReceipt;
    this.sandbox     = sinon.createSandbox();

    this.spies = {
      lastReceipt: {
        get    : this.sandbox.spy(this.lastReceipt, 'get'),
        isStale: this.sandbox.spy(this.lastReceipt, 'isStale'),
        update : this.sandbox.spy(this.lastReceipt, 'update'),
      },
    };
  }
开发者ID:RiseVision,项目名称:rise-node,代码行数:13,代码来源:BlocksModuleStub.ts

示例7: beforeEach

 beforeEach(() => {
   container = createContainer();
   container.bind(Symbols.api.utils.errorHandler).to(APIErrorHandler);
   sandbox = sinon.createSandbox();
   sendSpy = {send: sandbox.spy()};
   response = {status: () => sendSpy, send: sendSpy.send };
   responseStatusSpy = sandbox.spy(response, 'status');
   request = {url: {startsWith: sandbox.stub().callsFake((start) => !(start === '/v2') ) }};
   requestStub = request.url.startsWith;
   next = sandbox.spy();
   loggerStub = container.get(Symbols.helpers.logger);
   instance = container.get(Symbols.api.utils.errorHandler);
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:13,代码来源:errorHandler.spec.ts

示例8: it

 it('should call removeUnconfirmedTransaction when a tx is expired and has not signatures', async () => {
   await addMixedTransactionsAndFillPool(true);
   const removeUnconfirmedTransactionSpy = sandbox.spy(instance as any, 'removeUnconfirmedTransaction');
   instance.expireTransactions();
   expect(removeUnconfirmedTransactionSpy.called).to.be.true;
   expect(removeUnconfirmedTransactionSpy.callCount).to.be.equal(13);
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:7,代码来源:transactionPool.spec.ts

示例9: beforeEach

    beforeEach(() => {
      fakeApp                       = {
        options: sandbox.stub(),
        use    : sandbox.stub(),
      };
      (expressRunner as any).static = sandbox.stub().returns('static');

      (fakeBodyParser as any).raw        = sandbox.stub().returns('raw');
      (fakeBodyParser as any).urlencoded = sandbox.stub().returns('urlencoded');
      (fakeBodyParser as any).json       = sandbox.stub().returns('json');

      fakeMiddleware.logClientConnections = sandbox.stub().returns('logClientConnections');
      fakeMiddleware.attachResponseHeader = sandbox.stub().returns('attachResponseHeader');
      fakeMiddleware.applyAPIAccessRules  = sandbox.stub().returns('applyAPIAccessRules');
      fakeMiddleware.protoBuf             = sandbox.stub().returns('protoBuf');

      applyExpressLimitsStub  = sandbox.stub();
      compressionStub         = sandbox.stub().returns('compression');
      corsStub                = sandbox.stub().returns('cors');
      useContainerForHTTPStub = sandbox.stub();
      useExpressServerStub    = sandbox.stub();
      getMetadataSpy          = sandbox.spy(Reflect, 'getMetadata');

      containerStub = new ContainerStub(sandbox);
      containerStub.get.callsFake((s) => (s === Symbols.generic.expressApp) ? fakeApp : s.toString());

      instance = new ProxyAppManager.AppManager(appConfig, loggerStub, '1.0', genesisBlock, constants, []);

      (instance as any).container = containerStub;
    });
开发者ID:RiseVision,项目名称:rise-node,代码行数:30,代码来源:AppManager.spec.ts


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