本文整理汇总了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();
});