Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asimonok committed Dec 29, 2023
1 parent 4d2013e commit c50c15f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/components/FormPanel/FormPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,44 @@ describe('Panel', () => {
expect(selectors.buttonSubmit()).toBeDisabled();
});

it('Should allow to refresh dashboard', async () => {
const publish = jest.fn();
jest.mocked(getAppEvents).mockImplementation(
() =>
({
publish,
}) as any
);

await act(async () =>
render(
getComponent({
options: {
elements: [
{
...element,
value: '1',
},
],
elementValueChanged: `
context.grafana.refresh();
`,
},
})
)
);

/**
* Change value
*/
await act(async () => fireEvent.change(elementsSelectors.fieldString(), { target: { value: '11' } }));

/**
* Dashboard should be refreshed
*/
expect(publish).toHaveBeenCalledWith(expect.objectContaining({ type: 'variables-changed' }));
});

it('Should allow to manage submit button', async () => {
await act(async () =>
render(
Expand Down

0 comments on commit c50c15f

Please sign in to comment.