I am trying to test a particular scenario with help of jest.
SomeClient is exported as a non default class from the some/module and has a constructor and one of the methods like
SomeClient(string endpoint, string token) and getProperties(): Promise<Properties>
ConnectivityManager has a method isConnected whose signature is like
public static async isConnected(someClient: SomeClient): Promise<boolean> which also calls someClient.getProperties()
In test class ConnectivityManager.test.ts my code is like this
import { SomeClient } from 'some/module';
jest.mock('some/module', () => {
return {
SomeClient: jest.fn().mockImplementation(() => {
return {
getProperties: (): Promise<Properties> =>
new Promise((resolve) => {
resolve(mockResponseObject);
})
};
})
};
});
test('isConnected should be able to return true if SomeClient returns Properties', async () => {
const result = await ConnectivityManager.isConnected(someClientMock);
//someClientMock how do I get the mock object of type SomeClient to pass here?
}
How do I get the mock object of type SomeClient to pass to ConnectivityManager.isConnected?
const someClientMock = new SomeClient(....);