Skip to content

Commit

Permalink
[test] Always use & for nesting styles
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jan 1, 2023
1 parent 33a0e1c commit 4fd94e0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/mui-system/src/Box/Box.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function ComponentPropTest() {

function ThemeCallbackTest() {
<Box sx={{ background: (theme) => theme.palette.primary.main }} />;
<Box sx={{ ':hover': (theme) => ({ background: theme.palette.primary.main }) }} />;
<Box sx={{ '&:hover': (theme) => ({ background: theme.palette.primary.main }) }} />;
<Box sx={{ '& .some-class': (theme) => ({ background: theme.palette.primary.main }) }} />;
<Box maxWidth={(theme) => theme.breakpoints.values.sm} />;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-system/src/createBox.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function ComponentPropTest() {

function ThemeCallbackTest() {
<Box sx={{ background: (theme) => theme.palette.primary.main }} />;
<Box sx={{ ':hover': (theme) => ({ background: theme.palette.primary.main }) }} />;
<Box sx={{ '&:hover': (theme) => ({ background: theme.palette.primary.main }) }} />;
<Box sx={{ '& .some-class': (theme) => ({ background: theme.palette.primary.main }) }} />;
<Box maxWidth={(theme) => theme.breakpoints.values.sm} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ describe('styleFunctionSx', () => {
const result = styleFunctionSx({
theme,
sx: {
':hover': (t) => ({ background: t.palette.primary.main }),
'&:hover': (t) => ({ background: t.palette.primary.main }),
},
});

// Test the order
expect(result).to.deep.equal({ ':hover': { background: 'rgb(0, 0, 255)' } });
expect(result).to.deep.equal({ '&:hover': { background: 'rgb(0, 0, 255)' } });
});

it('works on nested selectors', () => {
Expand Down

0 comments on commit 4fd94e0

Please sign in to comment.