本文整理匯總了TypeScript中Sinon.fake函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fake函數的具體用法?TypeScript fake怎麽用?TypeScript fake使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了fake函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it(`calls the action handler`, function () {
const message = 'test';
const items = ['item'];
const cb = sinon.fake();
const cbArgs = [];
notifyManagerStub.notifyInfo.returns(Promise.resolve('btn'));
// @ts-ignore
const handleActionStub = sandbox.stub(extensionManager, 'handleAction');
return (
extensionManager
// @ts-ignore
.showCustomizationMessage(message, items, cb, cbArgs)
.then(() => {
expect(
notifyManagerStub.notifyInfo.calledOnceWithExactly(
message,
...items,
),
).to.be.true;
expect(handleActionStub.calledOnceWithExactly('btn', cb, cbArgs))
.to.be.true;
})
);
});
示例2: it
it(`when no callback arguments are provided`, function () {
const cb = sinon.fake();
const cbArgs = ['arg1', 'arg2', 'arg3'];
return (
extensionManager
// @ts-ignore
.handleAction(models.LangResourceKeys.reload, cb, cbArgs)
.then(() => {
// @ts-ignore
expect(extensionManager.customMsgShown).to.be.undefined;
// @ts-ignore
expect(extensionManager.callback).to.equal(cb);
expect(executeAndReloadStub.called).to.be.false;
expect(
configManagerStub.updateDontShowConfigManuallyChangedMessage
.called,
).to.be.false;
expect(configManagerStub.updateDisableDetection.called).to.be
.false;
expect(configManagerStub.updateAutoReload.called).to.be.false;
expect(
handleUpdatePresetStub.calledOnceWithExactly(cb, cbArgs),
).to.be.true;
})
);
});
示例3: beforeEach
beforeEach(() => {
crawler = new Crawler();
response = textResponse(url, 200, 'body');
crawler.createExecutor = sinon.stub().callsFake(() => immediateExecutor);
createRequest = sinon.stub().callsFake((referer: string, url: string) =>
succeedingRequest({
visitedUrls: [ url ],
lastVisitedUrl: url,
response
})
);
crawler.createRequest = createRequest;
success = sinon.fake();
failure = sinon.fake();
finished = sinon.stub();
});