Skip to content

Commit

Permalink
Add test for same renderToString ids per root
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Oct 22, 2022
1 parent 5400a88 commit 26b3341
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions hooks/test/browser/useId.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,31 @@ describe('useId', () => {
render(<App />, scratch);
expect(ids).to.deep.equal(['P491', 'P501']);
});

it('should reset for each renderToString roots', () => {
const ids = [];

function Foo() {
const id = useId();
ids.push(id);
return <p>{id}</p>;
}

function App() {
return (
<div>
<span>
<Foo />
</span>
<span>
<Foo />
</span>
</div>
);
}

const res1 = rts(<App />);
const res2 = rts(<App />);
expect(res1).to.equal(res2);
});
});

0 comments on commit 26b3341

Please sign in to comment.