From 09371096f3c92ba81986b6bf00b9806c4ef738c9 Mon Sep 17 00:00:00 2001 From: DiegoAndai Date: Fri, 6 Dec 2024 10:09:53 -0300 Subject: [PATCH] Refactor useCurrentColorScheme test --- .../src/cssVars/useCurrentColorScheme.test.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/mui-system/src/cssVars/useCurrentColorScheme.test.js b/packages/mui-system/src/cssVars/useCurrentColorScheme.test.js index 32ba4e9b67029a..0c2a61aa69fea7 100644 --- a/packages/mui-system/src/cssVars/useCurrentColorScheme.test.js +++ b/packages/mui-system/src/cssVars/useCurrentColorScheme.test.js @@ -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 ( -
- {mode}:{count.current} -
- ); + return
{mode}
; } - const expectedCount = reactMajor >= 19 ? 1 : 2; + const { container } = render(); - 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', () => {