Skip to content

Commit

Permalink
Refactor useCurrentColorScheme test
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Dec 6, 2024
1 parent 0ebf220 commit 0937109
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/mui-system/src/cssVars/useCurrentColorScheme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,23 @@ describe('useCurrentColorScheme', () => {
});

it('trigger a re-render for a multi color schemes', () => {
let effectRunCount = 0;
function Data() {
const { mode } = useCurrentColorScheme({
supportedColorSchemes: ['light', 'dark'],
defaultLightColorScheme: 'light',
defaultDarkColorScheme: 'dark',
});
const count = React.useRef(0);
React.useEffect(() => {
count.current += 1;
effectRunCount += 1;
});
return (
<div>
{mode}:{count.current}
</div>
);
return <div>{mode}</div>;
}
const expectedCount = reactMajor >= 19 ? 1 : 2;

const { container } = render(<Data />);

expect(container.firstChild.textContent).to.equal(`light:${expectedCount}`);
expect(container.firstChild.textContent).to.equal('light');
expect(effectRunCount).to.equal(2);
});

it('[noSsr] does not trigger a re-render', () => {
Expand Down

0 comments on commit 0937109

Please sign in to comment.