In my typescript code, I am using teh SSOAdminClient as follows:
import {
SSOAdminClient
} from '@aws-sdk/client-sso-admin';
const client = new SSOAdminClient({ region, credentials });
const obj = {
name: 'Bob',
age: 20
}
await SSOClient.send(obj);
I am using jest/sinon for testing, and I want to write a test to check whether the send function of the SSOClient is called with the obj object as an argument.
In my test file I have:
const spy = sinon.spy(SSOAdminClient.prototype, 'send');
spy.resolves();
expect(spy.calledOnceWith({ name: 'Bob', age: 20 })).toBeTruthy();
However, I get an error saying that calledOnceWith expects three arguments instead of 1 (in the src file there is only one argument for obj). When I click on the send method to check its function definition I can see the following lines:
send<InputType extends ClientInput, OutputType extends ClientOutput>(command: Command<ClientInput, InputType, ClientOutput, OutputType, SmithyResolvedConfiguration<HandlerOptions>>, options?: HandlerOptions): Promise<OutputType>;
send<InputType extends ClientInput, OutputType extends ClientOutput>(command: Command<ClientInput, InputType, ClientOutput, OutputType, SmithyResolvedConfiguration<HandlerOptions>>, cb: (err: any, data?: OutputType) => void): void;
send<InputType extends ClientInput, OutputType extends ClientOutput>(command: Command<ClientInput, InputType, ClientOutput, OutputType, SmithyResolvedConfiguration<HandlerOptions>>, options: HandlerOptions, cb: (err: any, data?: OutputType) => void): void;
From the 3rd line I understand that options and cb are supposed to be the 2nd and 3rd arguments, but how can I check what these actually are so that I can use them in the test? Alternatively am I supposed to write the test differently so that only one argument is expected (as you would expect by looking at the src code)?