Skip to content

Commit

Permalink
[Grid] Fix prop check for applying wrap-reverse (mui#30813)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hubbz authored and wladimirguerra committed Feb 2, 2022
1 parent a1af3a8 commit e29106b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/mui-material/src/Grid/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,8 @@ const GridRoot = styled('div', {
...(ownerState.zeroMinWidth && {
minWidth: 0,
}),
...(ownerState.wrap === 'nowrap' && {
flexWrap: 'nowrap',
}),
...(ownerState.wrap === 'reverse' && {
flexWrap: 'wrap-reverse',
...(ownerState.wrap !== 'wrap' && {
flexWrap: ownerState.wrap,
}),
}),
generateDirection,
Expand Down
25 changes: 25 additions & 0 deletions packages/mui-material/src/Grid/Grid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,29 @@ describe('<Grid />', () => {
marginBottom: '16px',
});
});

describe('prop: wrap', () => {
it('should wrap by default', () => {
render(<Grid container data-testid="wrap" />);
expect(screen.getByTestId('wrap')).toHaveComputedStyle({
flexWrap: 'wrap',
});
});

it('should apply nowrap class and style', () => {
const { container } = render(<Grid container wrap="nowrap" data-testid="wrap" />);
expect(container.firstChild).to.have.class('MuiGrid-wrap-xs-nowrap');
expect(screen.getByTestId('wrap')).toHaveComputedStyle({
flexWrap: 'nowrap',
});
});

it('should apply wrap-reverse class and style', () => {
const { container } = render(<Grid container wrap="wrap-reverse" data-testid="wrap" />);
expect(container.firstChild).to.have.class('MuiGrid-wrap-xs-wrap-reverse');
expect(screen.getByTestId('wrap')).toHaveComputedStyle({
flexWrap: 'wrap-reverse',
});
});
});
});

0 comments on commit e29106b

Please sign in to comment.