Skip to content

Commit

Permalink
adding back title and unit test checks
Browse files Browse the repository at this point in the history
  • Loading branch information
opauloh committed May 23, 2024
1 parent cc5a2bd commit 9e93014
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ describe('group selector', () => {
const { getByTestId } = render(<GroupSelector {...testProps} />);
expect(getByTestId('group-selector-dropdown').textContent).toBe('Group alerts by: Rule name');
});
it('Sets the Group by title from the title prop', () => {
const { getByTestId } = render(
<GroupSelector {...testProps} title="Group custom property by" />
);
expect(getByTestId('group-selector-dropdown').textContent).toBe(
'Group custom property by: Rule name'
);
});
it('Presents correct option when group selector dropdown is clicked', () => {
const { getByTestId } = render(<GroupSelector {...testProps} />);
fireEvent.click(getByTestId('group-selector-dropdown'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,17 @@ describe('Group Selector Hooks', () => {
type: ActionType.updateGroupOptions,
});
});

it('Supports custom group by title', () => {
const result = renderHook(() =>
useGetGroupSelector({
...defaultArgs,
title: 'Group custom property by',
})
);

expect(result.result.current.props.title).toEqual('Group custom property by');
});
});

describe('useGetGroupSelectorStateless', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ export const useGetGroupSelector = ({
fields,
maxGroupingLevels,
options,
title,
}}
/>
);
}, [groupingId, fields, maxGroupingLevels, onChange, selectedGroups, options]);
}, [groupingId, fields, maxGroupingLevels, onChange, selectedGroups, options, title]);
};

0 comments on commit 9e93014

Please sign in to comment.