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