Skip to content

Commit

Permalink
add loadingPosition* classes to button
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Jan 3, 2025
1 parent 02abe9d commit d3d0926
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/mui-material/src/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const useUtilityClasses = (ownerState) => {
`color${capitalize(color)}`,
disableElevation && 'disableElevation',
fullWidth && 'fullWidth',
loading && `loadingPosition${capitalize(loadingPosition)}`,
],
startIcon: ['icon', 'startIcon', `iconSize${capitalize(size)}`],
endIcon: ['icon', 'endIcon', `iconSize${capitalize(size)}`],
Expand Down
19 changes: 19 additions & 0 deletions packages/mui-material/src/Button/Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,5 +810,24 @@ describe('<Button />', () => {

expect(screen.getByRole('button')).to.have.text('loading…Test');
});

it('should have loading position class attached to root when `loading`', () => {
const { rerender } = render(<Button loading>Test</Button>);
expect(screen.getByRole('button')).to.have.class(classes.loadingPositionCenter);

rerender(
<Button loading loadingPosition="start">
Test
</Button>,
);
expect(screen.getByRole('button')).to.have.class(classes.loadingPositionStart);

rerender(
<Button loading loadingPosition="end">
Test
</Button>,
);
expect(screen.getByRole('button')).to.have.class(classes.loadingPositionEnd);
});
});
});

0 comments on commit d3d0926

Please sign in to comment.