Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sinon] allow partial arguments for calledWith #53467

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions types/sinon/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1117,20 +1117,20 @@ declare namespace Sinon {
*/
calledWith<TArgs extends any[]>(
spyOrSpyCall: SinonSpy<TArgs> | SinonSpyCall<TArgs>,
...args: MatchArguments<TArgs>
...args: Partial<MatchArguments<TArgs>>
Flarna marked this conversation as resolved.
Show resolved Hide resolved
): void;
/**
* Passes if spy was always called with the provided arguments.
* @param spy
* @param args
*/
alwaysCalledWith<TArgs extends any[]>(spy: SinonSpy<TArgs>, ...args: MatchArguments<TArgs>): void;
alwaysCalledWith<TArgs extends any[]>(spy: SinonSpy<TArgs>, ...args: Partial<MatchArguments<TArgs>>): void;
/**
* Passes if spy was never called with the provided arguments.
* @param spy
* @param args
*/
neverCalledWith<TArgs extends any[]>(spy: SinonSpy<TArgs>, ...args: MatchArguments<TArgs>): void;
neverCalledWith<TArgs extends any[]>(spy: SinonSpy<TArgs>, ...args: Partial<MatchArguments<TArgs>>): void;
/**
* Passes if spy was called with the provided arguments and no others.
* It’s possible to assert on a dedicated spy call: sinon.assert.calledWithExactly(spy.getCall(1), arg1, arg2, ...);.
Expand Down
6 changes: 6 additions & 0 deletions types/sinon/sinon-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function testAssert() {
sinon.assert.callOrder(spy, spyTwo);
sinon.assert.calledOn(spy, obj);
sinon.assert.calledOn(spy.firstCall, obj);
sinon.assert.calledWith(spy, "a", "b", "c");
sinon.assert.alwaysCalledOn(spy, obj);
sinon.assert.alwaysCalledWith(spy, "a", "b", "c");
sinon.assert.neverCalledWith(spy, "a", "b", "c");
Expand Down Expand Up @@ -342,11 +343,16 @@ function testAssert() {
sinon.assert.callOrder(typedSpy, spyTwo);
sinon.assert.calledOn(typedSpy, obj);
sinon.assert.calledOn(typedSpy.firstCall, obj);
sinon.assert.calledWith(typedSpy, "a", true);
sinon.assert.calledWith(typedSpy, "a");
sinon.assert.calledWith(typedSpy, "a", "b"); // $ExpectError
sinon.assert.alwaysCalledOn(typedSpy, obj);
sinon.assert.alwaysCalledWith(typedSpy, "a", "b", "c"); // $ExpectError
sinon.assert.alwaysCalledWith(typedSpy, "a", true);
sinon.assert.alwaysCalledWith(typedSpy, "a");
sinon.assert.neverCalledWith(typedSpy, "a", false);
sinon.assert.neverCalledWith(typedSpy, "a", "b"); // $ExpectError
sinon.assert.neverCalledWith(typedSpy, "a");
sinon.assert.calledWithExactly(typedSpy, "a", true);
sinon.assert.calledWithExactly(typedSpy, "a", "b"); // $ExpectError
sinon.assert.alwaysCalledWithExactly(typedSpy, "a", true);
Expand Down