Skip to content

Commit 7cbeb75

Browse files
authored
fix(dropdown): clean console errors in Dropdown.test.tsx (#3861)
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
1 parent b696cec commit 7cbeb75

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

packages/react-core/src/components/Dropdown/DropdownWithContext.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ class DropdownWithContext extends React.Component<DropdownProps & InjectedOuiaPr
3030
constructor(props: DropdownProps & InjectedOuiaProps) {
3131
super(props);
3232
if (props.dropdownItems && props.dropdownItems.length > 0 && props.children) {
33-
throw new Error(
34-
'Children and dropdownItems props have been provided. Only the dropdownItems prop items will be rendered '
33+
// eslint-disable-next-line no-console
34+
console.error(
35+
'Children and dropdownItems props have been provided. Only the dropdownItems prop items will be rendered'
3536
);
3637
}
3738
}

packages/react-core/src/components/Dropdown/Toggle.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ export class Toggle extends React.Component<ToggleProps> {
140140
parentRef,
141141
id,
142142
type,
143+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
144+
bubbleEvent,
143145
...props
144146
} = this.props;
145147
return (

packages/react-core/src/components/Dropdown/__tests__/Dropdown.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ describe('API', () => {
185185
});
186186

187187
test('dropdownItems and children console error ', () => {
188-
expect(() =>
188+
const myMock = jest.fn();
189+
global.console = { error: myMock } as any;
189190
mount(
190191
<Dropdown
191192
dropdownItems={dropdownItems}
@@ -195,7 +196,7 @@ describe('API', () => {
195196
<div>Children items</div>
196197
</Dropdown>
197198
)
198-
).toThrowError();
199+
expect(myMock).toBeCalledWith('Children and dropdownItems props have been provided. Only the dropdownItems prop items will be rendered');
199200
});
200201

201202
test('dropdownItems only, no console error ', () => {

0 commit comments

Comments
 (0)