Skip to content

Commit d3d0926

Browse files
committed
add loadingPosition* classes to button
1 parent 02abe9d commit d3d0926

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/mui-material/src/Button/Button.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const useUtilityClasses = (ownerState) => {
3333
`color${capitalize(color)}`,
3434
disableElevation && 'disableElevation',
3535
fullWidth && 'fullWidth',
36+
loading && `loadingPosition${capitalize(loadingPosition)}`,
3637
],
3738
startIcon: ['icon', 'startIcon', `iconSize${capitalize(size)}`],
3839
endIcon: ['icon', 'endIcon', `iconSize${capitalize(size)}`],

packages/mui-material/src/Button/Button.test.js

+19
Original file line numberDiff line numberDiff line change
@@ -810,5 +810,24 @@ describe('<Button />', () => {
810810

811811
expect(screen.getByRole('button')).to.have.text('loading…Test');
812812
});
813+
814+
it('should have loading position class attached to root when `loading`', () => {
815+
const { rerender } = render(<Button loading>Test</Button>);
816+
expect(screen.getByRole('button')).to.have.class(classes.loadingPositionCenter);
817+
818+
rerender(
819+
<Button loading loadingPosition="start">
820+
Test
821+
</Button>,
822+
);
823+
expect(screen.getByRole('button')).to.have.class(classes.loadingPositionStart);
824+
825+
rerender(
826+
<Button loading loadingPosition="end">
827+
Test
828+
</Button>,
829+
);
830+
expect(screen.getByRole('button')).to.have.class(classes.loadingPositionEnd);
831+
});
813832
});
814833
});

0 commit comments

Comments
 (0)