Skip to content

Commit

Permalink
fix mocked client construction due to 7.9-rc1 bump
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Jul 20, 2020
1 parent ae6d7bd commit c4be5d2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/core/server/elasticsearch/client/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,20 @@ const createInternalClientMock = (): DeeplyMockedKeys<Client> => {

mockify(client, omittedProps);

client.transport = {
// client got some read-only (getter) properties
// so we need to extend it to override the getter-only props.
const mock: any = { ...client };

mock.transport = {
request: jest.fn(),
};
client.close = jest.fn().mockReturnValue(Promise.resolve());
client.child = jest.fn().mockImplementation(() => createInternalClientMock());
client.on = jest.fn();
client.off = jest.fn();
client.once = jest.fn();
mock.close = jest.fn().mockReturnValue(Promise.resolve());
mock.child = jest.fn().mockImplementation(() => createInternalClientMock());
mock.on = jest.fn();
mock.off = jest.fn();
mock.once = jest.fn();

return (client as unknown) as DeeplyMockedKeys<Client>;
return (mock as unknown) as DeeplyMockedKeys<Client>;
};

export type ElasticSearchClientMock = DeeplyMockedKeys<ElasticsearchClient>;
Expand Down

0 comments on commit c4be5d2

Please sign in to comment.