|
1 | 1 | import * as React from 'react';
|
2 | 2 | import { expect } from 'chai';
|
3 | 3 | import { spy } from 'sinon';
|
4 |
| -import { createRenderer, fireEvent, act, screen, reactMajor } from '@mui/internal-test-utils'; |
| 4 | +import { createRenderer, fireEvent, act, screen } from '@mui/internal-test-utils'; |
5 | 5 | import {
|
6 | 6 | DEFAULT_MODE_STORAGE_KEY,
|
7 | 7 | DEFAULT_COLOR_SCHEME_STORAGE_KEY,
|
@@ -85,26 +85,23 @@ describe('useCurrentColorScheme', () => {
|
85 | 85 | });
|
86 | 86 |
|
87 | 87 | it('trigger a re-render for a multi color schemes', () => {
|
| 88 | + let effectRunCount = 0; |
88 | 89 | function Data() {
|
89 | 90 | const { mode } = useCurrentColorScheme({
|
90 | 91 | supportedColorSchemes: ['light', 'dark'],
|
91 | 92 | defaultLightColorScheme: 'light',
|
92 | 93 | defaultDarkColorScheme: 'dark',
|
93 | 94 | });
|
94 |
| - const count = React.useRef(0); |
95 | 95 | React.useEffect(() => {
|
96 |
| - count.current += 1; |
| 96 | + effectRunCount += 1; |
97 | 97 | });
|
98 |
| - return ( |
99 |
| - <div> |
100 |
| - {mode}:{count.current} |
101 |
| - </div> |
102 |
| - ); |
| 98 | + return <div>{mode}</div>; |
103 | 99 | }
|
104 |
| - const expectedCount = reactMajor >= 19 ? 1 : 2; |
| 100 | + |
105 | 101 | const { container } = render(<Data />);
|
106 | 102 |
|
107 |
| - expect(container.firstChild.textContent).to.equal(`light:${expectedCount}`); |
| 103 | + expect(container.firstChild.textContent).to.equal('light'); |
| 104 | + expect(effectRunCount).to.equal(2); |
108 | 105 | });
|
109 | 106 |
|
110 | 107 | it('[noSsr] does not trigger a re-render', () => {
|
|
0 commit comments