Files
react-test/packages/mui-material/src/Box/Box.spec.tsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-12-12 14:26:25 +09:00
import { Box as SystemBox, BoxProps as SystemBoxProps, createBox } from '@mui/system';
import { expectType } from '@mui/types';
import Box, { BoxProps as MaterialBoxProps } from '@mui/material/Box';
import { createTheme } from '@mui/material/styles';
function ThemeValuesCanBeSpread() {
<Box
sx={(theme) => ({
...theme.typography.body1,
color: theme.palette.primary.main,
})}
/>;
<Box
sx={(theme) => ({
...theme.mixins.toolbar,
color: theme.palette.primary.main,
})}
/>;
<Box
sx={(theme) => ({
...theme.mixins.toolbar,
color: 'primary.main',
})}
/>;
}
// Compatibility with Material UI's Box
const defaultTheme = createTheme({});
const CustomBox = createBox({ defaultTheme });
expectType<typeof Box, typeof CustomBox>(CustomBox);
// @ts-expect-error System's Box has different type than Material UI's Box
expectType<typeof SystemBox, typeof CustomBox>(CustomBox);
function ColorTest() {
<Box
color={(theme) => theme.vars.palette.common.black}
sx={(theme) => ({ backgroundColor: theme.vars.palette.background.default })}
/>;
}
function ComponentTest() {
return <span />;
}
expectType<SystemBoxProps['component'], MaterialBoxProps['component']>('span');
expectType<SystemBoxProps['component'], MaterialBoxProps['component']>(ComponentTest);