本文整理汇总了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);
}
};
})()
示例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);
});
示例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);
});
示例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},
]);
});
示例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();
}
};
}
示例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());
});
示例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);
});
示例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) {
示例9: afterEach
afterEach(() => {
existsStub.restore();
createStub.restore();
});