Skip to content

Commit 3e58b0a

Browse files
authored
Convert ReactDOMInvalidARIAHook to createRoot (#28129)
1 parent e2b93af commit 3e58b0a

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,37 @@
1111

1212
describe('ReactDOMInvalidARIAHook', () => {
1313
let React;
14-
let ReactTestUtils;
14+
let ReactDOMClient;
1515
let mountComponent;
16+
let act;
1617

1718
beforeEach(() => {
1819
jest.resetModules();
1920
React = require('react');
20-
ReactTestUtils = require('react-dom/test-utils');
21+
ReactDOMClient = require('react-dom/client');
22+
act = require('internal-test-utils').act;
2123

22-
mountComponent = function (props) {
23-
ReactTestUtils.renderIntoDocument(<div {...props} />);
24+
mountComponent = async function (props) {
25+
const container = document.createElement('div');
26+
const root = ReactDOMClient.createRoot(container);
27+
await act(() => {
28+
root.render(<div {...props} />);
29+
});
2430
};
2531
});
2632

2733
describe('aria-* props', () => {
28-
it('should allow valid aria-* props', () => {
29-
mountComponent({'aria-label': 'Bumble bees'});
34+
it('should allow valid aria-* props', async () => {
35+
await mountComponent({'aria-label': 'Bumble bees'});
3036
});
31-
it('should warn for one invalid aria-* prop', () => {
32-
expect(() => mountComponent({'aria-badprop': 'maybe'})).toErrorDev(
37+
it('should warn for one invalid aria-* prop', async () => {
38+
await expect(() => mountComponent({'aria-badprop': 'maybe'})).toErrorDev(
3339
'Warning: Invalid aria prop `aria-badprop` on <div> tag. ' +
3440
'For details, see https://reactjs.org/link/invalid-aria-props',
3541
);
3642
});
37-
it('should warn for many invalid aria-* props', () => {
38-
expect(() =>
43+
it('should warn for many invalid aria-* props', async () => {
44+
await expect(() =>
3945
mountComponent({
4046
'aria-badprop': 'Very tall trees',
4147
'aria-malprop': 'Turbulent seas',
@@ -45,25 +51,27 @@ describe('ReactDOMInvalidARIAHook', () => {
4551
'tag. For details, see https://reactjs.org/link/invalid-aria-props',
4652
);
4753
});
48-
it('should warn for an improperly cased aria-* prop', () => {
54+
it('should warn for an improperly cased aria-* prop', async () => {
4955
// The valid attribute name is aria-haspopup.
50-
expect(() => mountComponent({'aria-hasPopup': 'true'})).toErrorDev(
56+
await expect(() => mountComponent({'aria-hasPopup': 'true'})).toErrorDev(
5157
'Warning: Unknown ARIA attribute `aria-hasPopup`. ' +
5258
'Did you mean `aria-haspopup`?',
5359
);
5460
});
5561

56-
it('should warn for use of recognized camel case aria attributes', () => {
62+
it('should warn for use of recognized camel case aria attributes', async () => {
5763
// The valid attribute name is aria-haspopup.
58-
expect(() => mountComponent({ariaHasPopup: 'true'})).toErrorDev(
64+
await expect(() => mountComponent({ariaHasPopup: 'true'})).toErrorDev(
5965
'Warning: Invalid ARIA attribute `ariaHasPopup`. ' +
6066
'Did you mean `aria-haspopup`?',
6167
);
6268
});
6369

64-
it('should warn for use of unrecognized camel case aria attributes', () => {
70+
it('should warn for use of unrecognized camel case aria attributes', async () => {
6571
// The valid attribute name is aria-haspopup.
66-
expect(() => mountComponent({ariaSomethingInvalid: 'true'})).toErrorDev(
72+
await expect(() =>
73+
mountComponent({ariaSomethingInvalid: 'true'}),
74+
).toErrorDev(
6775
'Warning: Invalid ARIA attribute `ariaSomethingInvalid`. ARIA ' +
6876
'attributes follow the pattern aria-* and must be lowercase.',
6977
);

0 commit comments

Comments
 (0)