From dcbf2e38d1aa33f02f9d15d002fb2312ecf8b98e Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Tue, 28 Apr 2020 10:52:05 -0700 Subject: [PATCH] Fix client-side renderApp test - it was breaking on the new sendTelemetry helper (http.catch specifically, leading me to think http/context isn't being populated) - For now, I simply mocked the SendAppSearchTelemetry component to an empty state and listened for it being called --- .../enterprise_search/public/applications/index.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x-pack/plugins/enterprise_search/public/applications/index.test.ts b/x-pack/plugins/enterprise_search/public/applications/index.test.ts index 7ece7e153c15416..90d49a00e571f97 100644 --- a/x-pack/plugins/enterprise_search/public/applications/index.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/index.test.ts @@ -7,6 +7,11 @@ import { coreMock } from 'src/core/public/mocks'; import { renderApp } from '../applications'; +jest.mock('./shared/telemetry', () => ({ + SendAppSearchTelemetry: jest.fn(() => null), +})); +import { SendAppSearchTelemetry } from './shared/telemetry'; + describe('renderApp', () => { it('mounts and unmounts UI', () => { const params = coreMock.createAppMountParamters(); @@ -14,6 +19,7 @@ describe('renderApp', () => { const unmount = renderApp(core, params, {}); expect(params.element.querySelector('.setup-guide')).not.toBeNull(); + expect(SendAppSearchTelemetry).toHaveBeenCalled(); unmount(); expect(params.element.innerHTML).toEqual(''); });