Skip to content

Commit

Permalink
refresh event call
Browse files Browse the repository at this point in the history
  • Loading branch information
vitPinchuk committed Sep 11, 2024
1 parent d0764d4 commit ef64c60
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/components/EchartsPanel/EchartsPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,40 @@ describe('Panel', () => {
});
});

it('Should publish refresh method called', () => {
const publish = jest.fn();
jest.mocked(getAppEvents).mockImplementation(
() =>
({
publish,
}) as any
); // we need only these options

jest.mocked(echarts.init).mockImplementationOnce(
() =>
({
setOption: () => {},
on: jest.fn(),
off: jest.fn(),
clear: jest.fn(),
}) as any
); // we need only these options

render(
getComponent({
options: {
getOption: 'return { refresh: context.grafana.refresh() }',
},
})
);
expect(publish).toHaveBeenCalledWith({
type: 'variables-changed',
payload: {
refreshAll: true,
},
});
});

it('Should publish events with passed payload even with promise return', () => {
const publish = jest.fn();
jest.mocked(getAppEvents).mockImplementation(
Expand Down

0 comments on commit ef64c60

Please sign in to comment.