Skip to content

Commit

Permalink
[Menu] Increase test timeout (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored Sep 11, 2024
1 parent f8906ef commit db2f883
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions packages/mui-base/src/Menu/Item/MenuItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ describe('<Menu.Item />', () => {
refInstanceof: window.HTMLDivElement,
}));

it('perf: does not rerender menu items unnecessarily', async () => {
it('perf: does not rerender menu items unnecessarily', async function test() {
if (/jsdom/.test(window.navigator.userAgent)) {
this.skip();
}

const renderItem1Spy = spy();
const renderItem2Spy = spy();
const renderItem3Spy = spy();
Expand Down Expand Up @@ -99,12 +103,18 @@ describe('<Menu.Item />', () => {

// React renders twice in strict mode, so we expect twice the number of spy calls

await waitFor(() => {
expect(renderItem1Spy.callCount).to.equal(2); // '1' rerenders as it loses highlight
});
await waitFor(() => {
expect(renderItem2Spy.callCount).to.equal(2); // '2' rerenders as it receives highlight
});
await waitFor(
() => {
expect(renderItem1Spy.callCount).to.equal(4); // '1' rerenders as it loses highlight
},
{ timeout: 1000 },
);
await waitFor(
() => {
expect(renderItem2Spy.callCount).to.equal(4); // '2' rerenders as it receives highlight
},
{ timeout: 1000 },
);

// neither the highlighted nor the selected state of these options changed,
// so they don't need to rerender:
Expand Down

0 comments on commit db2f883

Please sign in to comment.