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