Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion packages/mui-material/src/styles/createTheme.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { expect } from 'chai';
import { createRenderer, isJsdom } from '@mui/internal-test-utils';
import { createRenderer, isJsdom, screen } from '@mui/internal-test-utils';
import {
alpha as systemAlpha,
lighten as systemLighten,
darken as systemDarken,
} from '@mui/system/colorManipulator';
import Button from '@mui/material/Button';
import Alert from '@mui/material/Alert';
import Box from '@mui/material/Box';
import GlobalStyles from '@mui/material/GlobalStyles';
import { ThemeProvider, createTheme, styled } from '@mui/material/styles';
import { deepOrange, green, grey } from '@mui/material/colors';
import createPalette from './createPalette';
Expand Down Expand Up @@ -782,4 +784,42 @@ describe('createTheme', () => {
);
});
});

// Skip WebKit and firefox because they have a slightly different value
it.skipIf(isJSDOM || !/chrome/.test(window.navigator.userAgent))(
'should build color-mix() on top of generated Material UI CSS variables',
() => {
function App() {
const theme = createTheme({
cssVariables: {
nativeColor: true,
},
});

return (
<ThemeProvider theme={theme}>
{/* This is just to replicate the global CSS file */}
<GlobalStyles
styles={{
':root': {
'--mui-palette-info-main': '#d3b613 !important', // !important is to take precedence over the default one. This is just for test, in real world case global CSS file should be used.
'--mui-palette-info-light': '#dfc21f !important',
},
}}
/>

<Alert variant="standard" severity="info" data-testid="alert">
Alert
</Alert>
</ThemeProvider>
);
}

render(<App />);

expect(screen.getByTestId('alert')).toHaveComputedStyle({
backgroundColor: 'oklch(0.981465 0.01628 97.7526)', // browser converts color-mix to oklch in window.getComputedStyle()
});
},
);
});
Loading
Loading