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


TypeScript SinonStub.restore方法代码示例

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


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

示例1: stub

		'status codes call process exit': (function () {
			let processExitStub: SinonStub;

			return {
				'beforeEach'() {
					processExitStub = stub(process, 'exit');
				},
				'afterEach'() {
					processExitStub.restore();
				},
				async 'Should not exit process if no status code is returned'() {
					defaultRunStub.returns(Promise.reject(new Error(errorMessage)));

					await yargsStub.command.firstCall.args[ 3 ]({ '_': [ 'group' ] });
					assert.isFalse(processExitStub.called);
				},
				async 'Should exit process if status code is returned'() {
					defaultRunStub.returns(Promise.reject({
						message: errorMessage,
						exitCode: 1
					}));

					await yargsStub.command.firstCall.args[ 3 ]({ '_': [ 'group' ] });
					assert.isTrue(processExitStub.called);
				}
			};
		})()
开发者ID:dylans,项目名称:cli,代码行数:27,代码来源:registerCommands.ts

示例2: beforeEach

 beforeEach(() => {
   numblocksToLoadStub.restore();
   findAllTxsStub = sandbox.stub(transactionsModel, 'findAll').resolves([]);
   blockLogicStub.stubs.getMinBytesSize.returns(184);
   blockLogicStub.stubs.getMaxBytesSize.returns(18000);
   transactionLogicStub.stubs.getMaxBytesSize.returns(700);
   transactionLogicStub.stubs.getMinBytesSize.returns(219);
   transactionLogicStub.stubs.getByteSizeByTxType.returns(219);
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:9,代码来源:transportV2API.spec.ts

示例3: test

test('ServiceWorkerManager.getRegistration() handles throws by returning null', async t => {
  getRegistrationStub.restore();
  getRegistrationStub = sandbox.stub(navigator.serviceWorker, 'getRegistration');

  getRegistrationStub.returns(new Promise(() => {
    throw new Error("HTTP NOT SUPPORTED");
  }));
  const result = await ServiceWorkerManager.getRegistration();
  t.is(result, null);
});
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:10,代码来源:ServiceWorkerManager.ts

示例4: it

    it('should call correct methods and return proper data for v1 finishRound', async () => {
      scope.dposV2 = false;
      scope.finishRound = true;
      const res = instance.undo();

      expect(updateMissedBlocks.calledOnce).to.be.true;
      expect(applyRound.calledOnce).to.be.true;
      expect(restoreVotesSnapshot.calledOnce).to.be.true;

      updateMissedBlocks.restore();
      applyRound.restore();

      expect(res).to.be.deep.eq([
        { updateMissed: true},
        { apply: 1},
        { apply: 2},
        { restorevotes: true},
      ]);
    });
开发者ID:RiseVision,项目名称:rise-node,代码行数:19,代码来源:round.spec.ts

示例5: createResolvers

export function createResolvers() {
	let rAFStub: SinonStub;
	let rICStub: SinonStub;

	function resolveRAF() {
		for (let i = 0; i < rAFStub.callCount; i++) {
			rAFStub.getCall(i).args[0]();
		}
		rAFStub.reset();
	}

	function resolveRIC() {
		for (let i = 0; i < rICStub.callCount; i++) {
			rICStub.getCall(i).args[0]();
		}
		rICStub.reset();
	}

	return {
		resolve() {
			resolveRAF();
			resolveRIC();
		},
		stub() {
			rAFStub = stub(global, 'requestAnimationFrame').returns(1);
			if (global.requestIdleCallback) {
				rICStub = stub(global, 'requestIdleCallback').returns(1);
			}
			else {
				rICStub = stub(global, 'setTimeout').returns(1);
			}
		},
		restore() {
			rAFStub.restore();
			rICStub.restore();
		}
	};
}
开发者ID:bitpshr,项目名称:widgets,代码行数:38,代码来源:util.ts

示例6: beforeEach

 beforeEach(() => {
   txGeneratorStub    = sandbox.stub();
   afterTxPromiseStub = sandbox.stub();
   sumRoundStub       = sandbox.stub(instance as any, 'sumRound');
   roundSums          = {
     roundDelegates: ['delegate1', 'delegate2'],
     roundFees     : 0,
     roundRewards  : [0],
   };
   sumRoundStub.returns(roundSums);
   getOutsidersStub = sandbox.stub(instance as any, 'getOutsiders');
   getOutsidersStub.resolves([]);
   innerTickStub.restore();
   appStateStub.stubs.set.returns(void 0);
   roundsLogicStub.stubs.calcRound.returns(1);
   block.height  = 98;
   dbHelpersStub = container.get(Symbols.helpers.db);
   dbHelpersStub.enqueueResponse('performOps', Promise.resolve());
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:19,代码来源:rounds.spec.ts

示例7: it

  it('Should notify successful and show channel as requested', async () => {
    // For this particular test, we need it to return a different value
    mShowInformation.restore();
    mShowInformation = stub(window, 'showInformationMessage').returns(
      Promise.resolve(SHOW_BUTTON_TEXT)
    );
    const observable = new ReplaySubject<number | undefined>();
    observable.next(0);

    const notificationService = NotificationService.getInstance();
    await notificationService.reportExecutionStatus('mock command', observable);

    assert.calledOnce(mShow);
    assert.calledWith(
      mShowInformation,
      'mock command successfully ran',
      SHOW_BUTTON_TEXT
    );
    assert.notCalled(mShowWarningMessage);
    assert.notCalled(mShowErrorMessage);
  });
开发者ID:nertofiveone,项目名称:salesforcedx-vscode,代码行数:21,代码来源:index.test.ts

示例8: registerSuite

registerSuite('npmInstall', {
	before() {
		npmInstall = require('../../src/npmInstall');
	},
	beforeEach() {
		spawnOnStub = stub();
		const spawnOnResponse = {
			on: spawnOnStub
		};

		spawnOnStub.returns(spawnOnResponse);
		spawnStub = stub(cs, 'spawn').returns(spawnOnResponse);
	},
	afterEach() {
		spawnStub.restore();
	},

	tests: {
		async 'Should call spawn to run an npm process'() {
			spawnOnStub.onFirstCall().callsArg(1);
			await npmInstall.default();
			assert.isTrue(spawnStub.calledOnce);
		},
		async 'Should reject with an error when spawn throws an error'() {
			const errorMessage = 'test error message';
			spawnOnStub.onSecondCall().callsArgWith(1, new Error(errorMessage));
			try {
				await npmInstall.default();
				assert.fail(null, null, 'Should not get here');
			} catch (error) {
开发者ID:dojo,项目名称:cli,代码行数:30,代码来源:npmInstall.ts

示例9: afterEach

 afterEach(() => {
   existsStub.restore();
   createStub.restore();
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:4,代码来源:peers.spec.ts


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