Skip to content

Commit

Permalink
Remove excessive setup
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Oct 28, 2020
1 parent 2c410ad commit 63b24bf
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions packages/material-ui/src/styles/experimentalStyled.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,38 +97,26 @@ describe('experimentalStyled', () => {
});

describe('dynamic styles', () => {
/**
* @type {ReturnType<typeof styled>}
*/
let Div;

/**
* @type {ReturnType<typeof styled>}
*/
let DivObj;

before(() => {
Div = styled('div')`
it('can adapt styles to props', () => {
const Div = styled('div')`
font-size: ${(props) => props.scale * 8}px;
padding-left: ${(props) => props.scale * 2}px;
`;

DivObj = styled('div')((props) => ({
fontSize: `${props.scale * 8}px`,
paddingLeft: `${props.scale * 2}px`,
}));
});

it('can adapt styles to props', () => {
render(<Div scale={4} data-testid="target" />);

expect(screen.getByTestId('target')).toHaveComputedStyle({
fontSize: '32px',
paddingLeft: '8px',
});
});

it('can adapt styles to props when styles are object', () => {
const DivObj = styled('div')((props) => ({
fontSize: `${props.scale * 8}px`,
paddingLeft: `${props.scale * 2}px`,
}));
render(<DivObj scale={4} data-testid="target" />);

expect(screen.getByTestId('target')).toHaveComputedStyle({
fontSize: '32px',
paddingLeft: '8px',
Expand Down

0 comments on commit 63b24bf

Please sign in to comment.