Given this relatively contrived class that gets a single record from Elasticsearch (or any datastore for that matter):
export default class UserRepoImpl implements UserRepo {
constructor(private readonly esClient: ElasticsearchClient) {}
public async getUser(id: string): Promise<User> {
const response = await this.esClient.request('GET', `/users/_doc/${id}`);
return response._source;
}
}
How do I write a test that will instantiate a UserRepoImpl for me but insert a mocked ElasticsearchClient as the argument to the constructor?