Skip to content

Commit

Permalink
Test slots of Avatar, AvatarGroup and Badge
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj committed Nov 7, 2022
1 parent 9316b59 commit 39cf599
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
14 changes: 7 additions & 7 deletions packages/mui-joy/src/Avatar/Avatar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import PersonIcon from '../internal/svg-icons/Person';
describe('<Avatar />', () => {
const { render } = createRenderer();

describeConformance(<Avatar />, () => ({
describeConformance(<Avatar alt="dummy image" src="/dummy-image.jpg" />, () => ({
classes,
inheritComponent: 'div',
render,
Expand All @@ -21,6 +21,10 @@ describe('<Avatar />', () => {
testDeepOverrides: { slotName: 'fallback', slotClassName: classes.fallback },
testVariantProps: { variant: 'solid' },
testCustomVariant: true,
slots: {
root: { expectedClassName: classes.root },
img: { expectedClassName: classes.img },
},
skip: ['classesRoot', 'componentsProp'],
}));

Expand Down Expand Up @@ -96,9 +100,7 @@ describe('<Avatar />', () => {

it('should be able to add more props to the image', () => {
const onError = spy();
const { container } = render(
<Avatar src="/fake.png" slotProps={{ img: { onError } }} />,
);
const { container } = render(<Avatar src="/fake.png" slotProps={{ img: { onError } }} />);
const img = container.querySelector('img');
fireEvent.error(img);
expect(onError.callCount).to.equal(1);
Expand All @@ -116,9 +118,7 @@ describe('<Avatar />', () => {

it('should be able to add more props to the image', () => {
const onError = spy();
const { container } = render(
<Avatar src="/fake.png" slotProps={{ img: { onError } }} />,
);
const { container } = render(<Avatar src="/fake.png" slotProps={{ img: { onError } }} />);
const img = container.querySelector('img');
fireEvent.error(img);
expect(onError.callCount).to.equal(1);
Expand Down
3 changes: 3 additions & 0 deletions packages/mui-joy/src/AvatarGroup/AvatarGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ describe('<AvatarGroup />', () => {
testComponentPropWith: 'span',
testVariantProps: { variant: 'solid' },
testCustomVariant: true,
slots: {
root: { expectedClassName: classes.root },
},
skip: ['classesRoot', 'componentsProp'],
}));

Expand Down
6 changes: 5 additions & 1 deletion packages/mui-joy/src/Badge/Badge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('<Badge />', () => {
};

describeConformance(
<Badge>
<Badge badgeContent="1">
<button />
</Badge>,
() => ({
Expand All @@ -34,6 +34,10 @@ describe('<Badge />', () => {
muiName: 'JoyBadge',
testVariantProps: { color: 'neutral', variant: 'soft' },
testCustomVariant: true,
slots: {
root: { expectedClassName: classes.root },
badge: { expectedClassName: classes.badge },
},
skip: ['classesRoot', 'componentsProp'],
}),
);
Expand Down

0 comments on commit 39cf599

Please sign in to comment.