MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / expectCall

Function expectCall

front_end/testing/ExpectStubCall.ts:18–30  ·  view source on GitHub ↗
(
    stub: sinon.SinonStub<TArgs, TReturnValue>,
    options: {fakeFn?: (...args: TArgs) => TReturnValue, callCount?: number} = {})

Source from the content-addressed store, hash-verified

16 */
17// eslint-disable-next-line @typescript-eslint/no-explicit-any
18export function expectCall<TArgs extends any[] = any[], TReturnValue = any>(
19 stub: sinon.SinonStub<TArgs, TReturnValue>,
20 options: {fakeFn?: (...args: TArgs) => TReturnValue, callCount?: number} = {}): Promise<TArgs> {
21 return new Promise<TArgs>(resolve => {
22 // eslint-disable-next-line @typescript-eslint/no-explicit-any
23 stub.callsFake(function(this: any, ...args: TArgs) {
24 if (stub.callCount >= (options.callCount ?? 1)) {
25 resolve(args);
26 }
27 return (options.fakeFn ? options.fakeFn.apply(this, args) : undefined) as TReturnValue;
28 });
29 });
30}
31
32/**
33 * Returns a Promise that resolves with the arguments of the `stub`'s call once

Calls 1

applyMethod · 0.45

Tested by 4

updatesUiOnEventFunction · 0.68
addUISourceCodeFunction · 0.68
addScriptFunction · 0.68
addStyleSheetFunction · 0.68