Skip to content

Commit e362e8c

Browse files
committed
fix tests broken in previous commit
1 parent bee76ce commit e362e8c

File tree

8 files changed

+18
-11
lines changed

8 files changed

+18
-11
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createContext } from 'react';
12
import {
23
Drawer,
34
DrawerActions,
@@ -129,7 +130,7 @@ test(`Drawer has resizable callback and id`, () => {
129130
});
130131

131132
test('Resizeable DrawerPanelContent can be wrapped in a context without causing an error', async () => {
132-
const TestContext = React.createContext({});
133+
const TestContext = createContext({});
133134

134135
const consoleError = jest.spyOn(console, 'error').mockImplementation();
135136

packages/react-core/src/components/Form/__tests__/__snapshots__/FormGroup.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ exports[`FormGroup should render form group variant without label 1`] = `
154154
</DocumentFragment>
155155
`;
156156

157-
exports[`FormGroup should render form group with additonal label info 1`] = `
157+
exports[`FormGroup should render form group with additional label info 1`] = `
158158
<DocumentFragment>
159159
<div
160160
class="pf-v6-c-form__group"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from 'react';
12
import { fireEvent, render, screen } from '@testing-library/react';
23
import { NumberInput } from '../NumberInput';
34
import userEvent from '@testing-library/user-event';
@@ -215,7 +216,7 @@ describe('numberInput', () => {
215216
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
216217

217218
const NumberInputWrapper = () => {
218-
const [value, setValue] = React.useState(0);
219+
const [value, setValue] = useState(0);
219220
const onChange = (event) => setValue(event.currentTarget.value);
220221
const inputProps = { onChange };
221222

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createRef } from 'react';
12
import '@testing-library/jest-dom';
23

34
import { render, screen } from '@testing-library/react';
@@ -148,7 +149,7 @@ test('Does not throw console error when aria-label is given but no id', () => {
148149
});
149150

150151
test('TextArea can be accessed via passed ref', () => {
151-
const testRef: React.RefObject<HTMLTextAreaElement | null> = React.createRef();
152+
const testRef: React.RefObject<HTMLTextAreaElement | null> = createRef();
152153
render(<TextArea ref={testRef} />);
153154
global.scrollTo = jest.fn();
154155
testRef.current?.focus();

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useContext } from 'react';
12
import { render, screen } from '@testing-library/react';
23
import '@testing-library/jest-dom';
34
import styles from '@patternfly/react-styles/css/components/TextInputGroup/text-input-group';
@@ -73,7 +74,7 @@ describe('TextInputGroup', () => {
7374

7475
it('passes isDisabled=false to children via a context when isDisabled prop is not passed', () => {
7576
const TestComponent: React.FunctionComponent = () => {
76-
const context = React.useContext(TextInputGroupContext);
77+
const context = useContext(TextInputGroupContext);
7778

7879
return <button disabled={context.isDisabled} />;
7980
};
@@ -91,7 +92,7 @@ describe('TextInputGroup', () => {
9192

9293
it('passes isDisabled=true to children via a context when isDisabled prop is passed', () => {
9394
const TestComponent: React.FunctionComponent = () => {
94-
const context = React.useContext(TextInputGroupContext);
95+
const context = useContext(TextInputGroupContext);
9596

9697
return <button disabled={context.isDisabled} />;
9798
};

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createRef, useState } from 'react';
12
import { render, screen } from '@testing-library/react';
23
import { Tooltip } from '../Tooltip';
34
import userEvent from '@testing-library/user-event';
@@ -27,7 +28,7 @@ test('Renders with aria-live of off by default when triggerRef is not passed', a
2728
});
2829

2930
test('Renders with aria-live of polite by default when triggerRef is passed', async () => {
30-
const triggerRef = React.createRef();
31+
const triggerRef = createRef();
3132
render(<Tooltip triggerRef={triggerRef} isVisible content="Test content" />);
3233

3334
const tooltip = await screen.findByRole('tooltip');
@@ -94,7 +95,7 @@ test('Does not call onTooltipHidden before tooltip is hidden', async () => {
9495
const user = userEvent.setup();
9596

9697
const TooltipCallback = () => {
97-
const [isVisible, setIsVisible] = React.useState(false);
98+
const [isVisible, setIsVisible] = useState(false);
9899

99100
return (
100101
<Tooltip trigger="manual" isVisible={isVisible} onTooltipHidden={onTooltipHiddenMock} content="Test content">
@@ -114,7 +115,7 @@ test.skip('Calls onTooltipHidden when tooltip is hidden', async () => {
114115
const user = userEvent.setup();
115116

116117
const TooltipCallback = () => {
117-
const [isVisible, setIsVisible] = React.useState(true);
118+
const [isVisible, setIsVisible] = useState(true);
118119

119120
return (
120121
<Tooltip trigger="manual" isVisible={isVisible} onTooltipHidden={onTooltipHiddenMock} content="Test content">

packages/react-core/src/components/Wizard/__tests__/WizardToggle.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from 'react';
12
import { render, screen } from '@testing-library/react';
23
import userEvent from '@testing-library/user-event';
34

@@ -94,7 +95,7 @@ test('unsets expanded properties when using the Escape key', async () => {
9495
});
9596

9697
const WizardToggleExpand = (props) => {
97-
const [isExpanded, setIsExpanded] = React.useState(false);
98+
const [isExpanded, setIsExpanded] = useState(false);
9899

99100
return (
100101
<WizardToggle

packages/react-core/src/deprecated/components/Wizard/__tests__/Wizard.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from 'react';
12
import { render, screen } from '@testing-library/react';
23
import { Wizard, WizardStepFunctionType, WizardStep } from '../Wizard';
34
import { DrawerPanelContent, DrawerHead } from '../../../../../src/components/Drawer';
@@ -283,7 +284,7 @@ test('wiz with disable sub step', () => {
283284

284285
test('startAtStep can be used to externally control the current step of the wizard', async () => {
285286
const WizardTest = () => {
286-
const [step, setStep] = React.useState(1);
287+
const [step, setStep] = useState(1);
287288

288289
const incrementStep = () => {
289290
setStep((prevStep) => prevStep + 1);

0 commit comments

Comments
 (0)