Skip to content

Commit

Permalink
Add fast refresh test
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Oct 29, 2024
1 parent bdfe9fe commit a2c9e7a
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/react-refresh/src/__tests__/ReactFreshIntegration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,52 @@ describe('ReactFreshIntegration', () => {
}
});

// @gate enableActivity
it('does not re-create refs for Activity hidden', async () => {
if (__DEV__) {
await render(`
import {unstable_Activity as Activity} from 'react';
export default function App() {
return (
<Activity mode="hidden">
<div ref={(node) => {
if (node === null) {
throw new Error('callback ref should never be null')
}
return () => {
// ignore
}
}}>A</div>
</Activity>
);
};
`);
const el = container.firstChild;
expect(el.textContent).toBe('A');
await patch(`
import {unstable_Activity as Activity} from 'react';
export default function App() {
return (
<Activity mode="hidden">
<div ref={(node) => {
if (node === null) {
throw new Error('callback ref should never be null.')
}
return () => {
// ignore
}
}}>A</div>
</Activity>
);
};
`);
expect(container.firstChild).toBe(el);
expect(el.textContent).toBe('A');
}
});

it('reloads HOCs if they return functions', async () => {
if (__DEV__) {
await render(`
Expand Down

0 comments on commit a2c9e7a

Please sign in to comment.