Skip to content

Commit d1ba1e0

Browse files
committed
[Unzyme] src/core/packages/mount-utils :shipit: (elastic#226428)
## Summary Resolves elastic#224000 Moved to react testing library. Tests pass but I'm getting this warning now: ``` Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot ``` When I tried to move to createRoot it caused other issues so I'm not sure how to continue or if we should ignore the warning 🤔 @Dosant (cherry picked from commit 1e03b3a)
1 parent 924a2b6 commit d1ba1e0

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/core/packages/mount-utils/browser-internal/src/mount.test.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import React from 'react';
11-
import { mount } from 'enzyme';
11+
import { render } from '@testing-library/react';
1212
import { MountWrapper, mountReactNode } from './mount';
1313

1414
describe('MountWrapper', () => {
@@ -21,8 +21,8 @@ describe('MountWrapper', () => {
2121
return () => {};
2222
};
2323
const wrapper = <MountWrapper mount={mountPoint} />;
24-
const container = mount(wrapper);
25-
expect(container.html()).toMatchInlineSnapshot(
24+
const container = render(wrapper);
25+
expect(container.container.innerHTML).toMatchInlineSnapshot(
2626
`"<div class=\\"kbnMountWrapper\\"><p class=\\"bar\\">hello</p></div>"`
2727
);
2828
});
@@ -37,32 +37,31 @@ describe('MountWrapper', () => {
3737
};
3838

3939
const wrapper = <MountWrapper mount={mountPoint} />;
40-
const container = mount(wrapper);
41-
expect(container.html()).toMatchInlineSnapshot(
40+
const container = render(wrapper);
41+
expect(container.container.innerHTML).toMatchInlineSnapshot(
4242
`"<div class=\\"kbnMountWrapper\\"><p>initial</p></div>"`
4343
);
4444

4545
el.textContent = 'changed';
46-
container.update();
47-
expect(container.html()).toMatchInlineSnapshot(
46+
expect(container.container.innerHTML).toMatchInlineSnapshot(
4847
`"<div class=\\"kbnMountWrapper\\"><p>changed</p></div>"`
4948
);
5049
});
5150

5251
it('can render a detached react component', () => {
5352
const mountPoint = mountReactNode(<span>detached</span>);
5453
const wrapper = <MountWrapper mount={mountPoint} />;
55-
const container = mount(wrapper);
56-
expect(container.html()).toMatchInlineSnapshot(
54+
const container = render(wrapper);
55+
expect(container.container.innerHTML).toMatchInlineSnapshot(
5756
`"<div class=\\"kbnMountWrapper\\"><span>detached</span></div>"`
5857
);
5958
});
6059

6160
it('accepts a className prop to override default className', () => {
6261
const mountPoint = mountReactNode(<span>detached</span>);
6362
const wrapper = <MountWrapper mount={mountPoint} className="customClass" />;
64-
const container = mount(wrapper);
65-
expect(container.html()).toMatchInlineSnapshot(
63+
const container = render(wrapper);
64+
expect(container.container.innerHTML).toMatchInlineSnapshot(
6665
`"<div class=\\"customClass\\"><span>detached</span></div>"`
6766
);
6867
});

0 commit comments

Comments
 (0)