Skip to content

Commit

Permalink
Add tests to FilterPopup
Browse files Browse the repository at this point in the history
  • Loading branch information
asimonok committed Aug 15, 2024
1 parent ff0bf96 commit e47321d
Show file tree
Hide file tree
Showing 20 changed files with 1,426 additions and 150 deletions.
3 changes: 3 additions & 0 deletions src/__mocks__/@grafana/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ beforeEach(() => {
module.exports = {
...actual,
getTemplateSrv,
locationService: {
partial: jest.fn(),
},
};
28 changes: 28 additions & 0 deletions src/__mocks__/@grafana/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ const SelectMock = ({

const Select = jest.fn(SelectMock);

/**
* Mock Button Select
*/
const ButtonSelect = jest.fn(SelectMock);

/**
* Mock Button Row Toolbar
*/
Expand All @@ -99,15 +104,38 @@ const ToolbarButtonRowMock = ({ leftItems, children }: any) => {

const ToolbarButtonRow = jest.fn(ToolbarButtonRowMock);

/**
* Mock TimeRangeInput component
*/
const TimeRangeInputMock = ({ onChange, ...restProps }: any) => {
return (
<input
data-testid={restProps['data-testid']}
value={restProps.value}
onChange={(event) => {
if (onChange) {
onChange(event.target.value);
}
}}
/>
);
};

const TimeRangeInput = jest.fn(TimeRangeInputMock);

beforeEach(() => {
Button.mockImplementation(ButtonMock);
Select.mockImplementation(SelectMock);
ButtonSelect.mockImplementation(SelectMock);
ToolbarButtonRow.mockImplementation(ToolbarButtonRowMock);
TimeRangeInput.mockImplementation(TimeRangeInputMock);
});

module.exports = {
...actual,
Select,
Button,
ToolbarButtonRow,
ButtonSelect,
TimeRangeInput,
};
Loading

0 comments on commit e47321d

Please sign in to comment.