Skip to content

Commit 39cf599

Browse files
committed
Test slots of Avatar, AvatarGroup and Badge
1 parent 9316b59 commit 39cf599

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

packages/mui-joy/src/Avatar/Avatar.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import PersonIcon from '../internal/svg-icons/Person';
1010
describe('<Avatar />', () => {
1111
const { render } = createRenderer();
1212

13-
describeConformance(<Avatar />, () => ({
13+
describeConformance(<Avatar alt="dummy image" src="/dummy-image.jpg" />, () => ({
1414
classes,
1515
inheritComponent: 'div',
1616
render,
@@ -21,6 +21,10 @@ describe('<Avatar />', () => {
2121
testDeepOverrides: { slotName: 'fallback', slotClassName: classes.fallback },
2222
testVariantProps: { variant: 'solid' },
2323
testCustomVariant: true,
24+
slots: {
25+
root: { expectedClassName: classes.root },
26+
img: { expectedClassName: classes.img },
27+
},
2428
skip: ['classesRoot', 'componentsProp'],
2529
}));
2630

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

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

117119
it('should be able to add more props to the image', () => {
118120
const onError = spy();
119-
const { container } = render(
120-
<Avatar src="/fake.png" slotProps={{ img: { onError } }} />,
121-
);
121+
const { container } = render(<Avatar src="/fake.png" slotProps={{ img: { onError } }} />);
122122
const img = container.querySelector('img');
123123
fireEvent.error(img);
124124
expect(onError.callCount).to.equal(1);

packages/mui-joy/src/AvatarGroup/AvatarGroup.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ describe('<AvatarGroup />', () => {
1818
testComponentPropWith: 'span',
1919
testVariantProps: { variant: 'solid' },
2020
testCustomVariant: true,
21+
slots: {
22+
root: { expectedClassName: classes.root },
23+
},
2124
skip: ['classesRoot', 'componentsProp'],
2225
}));
2326

packages/mui-joy/src/Badge/Badge.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('<Badge />', () => {
2222
};
2323

2424
describeConformance(
25-
<Badge>
25+
<Badge badgeContent="1">
2626
<button />
2727
</Badge>,
2828
() => ({
@@ -34,6 +34,10 @@ describe('<Badge />', () => {
3434
muiName: 'JoyBadge',
3535
testVariantProps: { color: 'neutral', variant: 'soft' },
3636
testCustomVariant: true,
37+
slots: {
38+
root: { expectedClassName: classes.root },
39+
badge: { expectedClassName: classes.badge },
40+
},
3741
skip: ['classesRoot', 'componentsProp'],
3842
}),
3943
);

0 commit comments

Comments
 (0)