Skip to content

Commit f18af00

Browse files
committed
Update TelemetryLogic to use new getListeners helper
1 parent b9a5a15 commit f18af00

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

x-pack/plugins/enterprise_search/public/applications/shared/telemetry/telemetry_logic.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { resetContext } from 'kea';
8-
97
import { JSON_HEADER as headers } from '../../../../common/constants';
10-
import { mockHttpValues } from '../../__mocks__/http_logic.mock';
8+
import { LogicMounter, mockHttpValues } from '../../__mocks__';
119

12-
import { TelemetryLogic } from './';
10+
import { TelemetryLogic } from './telemetry_logic';
1311

1412
describe('Telemetry logic', () => {
13+
const { mount, getListeners } = new LogicMounter(TelemetryLogic);
1514
const { http } = mockHttpValues;
1615

1716
beforeEach(() => {
1817
jest.clearAllMocks();
19-
resetContext({});
20-
TelemetryLogic.mount();
18+
mount();
2119
});
2220

2321
describe('sendTelemetry', () => {
@@ -36,11 +34,7 @@ describe('Telemetry logic', () => {
3634

3735
it('throws an error if the telemetry endpoint fails', async () => {
3836
http.put.mockImplementationOnce(() => Promise.reject());
39-
40-
// To capture thrown errors, we have to call the listener fn directly
41-
// instead of using `TelemetryLogic.actions.sendTelemetry` - this is
42-
// due to how Kea invokes/wraps action fns by design.
43-
const { sendTelemetry } = (TelemetryLogic.inputs[0] as any).listeners({ actions: {} });
37+
const { sendTelemetry } = getListeners();
4438

4539
await expect(sendTelemetry({ action: '', metric: '', product: '' })).rejects.toThrow(
4640
'Unable to send telemetry'

0 commit comments

Comments
 (0)