Skip to content

Commit ba98cb7

Browse files
committed
Fix Joy useSlot() test
1 parent 6de54e0 commit ba98cb7

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

packages/mui-joy/src/utils/useSlot.test.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ describe('useSlot', () => {
4545
className?: string;
4646
component?: React.ElementType;
4747
href?: string;
48-
components?: { root?: React.ElementType; decorator?: React.ElementType };
49-
componentsProps?: {
48+
slots?: { root?: React.ElementType; decorator?: React.ElementType };
49+
slotProps?: {
5050
root?: SlotComponentProps<'button', Record<string, any>, {}>;
5151
decorator?: SlotComponentProps<'span', { size?: 'sm' | 'md' } & Record<string, any>, {}>;
5252
};
@@ -92,7 +92,7 @@ describe('useSlot', () => {
9292

9393
it('should append classes', () => {
9494
const { getByRole } = render(
95-
<Item className="foo-bar" componentsProps={{ decorator: { className: 'foo-bar' } }} />,
95+
<Item className="foo-bar" slotProps={{ decorator: { className: 'foo-bar' } }} />,
9696
);
9797
expect(getByRole('button')).to.have.class('root');
9898
expect(getByRole('button')).to.have.class('foo-bar');
@@ -106,13 +106,13 @@ describe('useSlot', () => {
106106
});
107107

108108
it('slot ownerstate should be overriable', () => {
109-
const { getByRole } = render(<Item componentsProps={{ decorator: { size: 'sm' } }} />);
109+
const { getByRole } = render(<Item slotProps={{ decorator: { size: 'sm' } }} />);
110110
expect(getByRole('button').firstChild).to.have.class('size-sm');
111111
});
112112

113-
it('componentsProps has higher priority', () => {
113+
it('slotProps has higher priority', () => {
114114
const { getByRole } = render(
115-
<Item data-item="foo" componentsProps={{ root: { 'data-item': 'bar' } }} />,
115+
<Item data-item="foo" slotProps={{ root: { 'data-item': 'bar' } }} />,
116116
);
117117
expect(getByRole('button')).to.have.attribute('data-item', 'bar');
118118
});
@@ -122,15 +122,15 @@ describe('useSlot', () => {
122122
expect(getByRole('link')).toBeVisible();
123123
});
124124

125-
it('use componentsProps `component` over `component` prop', () => {
125+
it('use slotProps `component` over `component` prop', () => {
126126
const { getByRole } = render(
127-
<Item component="div" componentsProps={{ root: { component: 'a', href: '/' } }} />,
127+
<Item component="div" slotProps={{ root: { component: 'a', href: '/' } }} />,
128128
);
129129
expect(getByRole('link')).toBeVisible();
130130
});
131131

132132
it('can change decorator leaf component', () => {
133-
const { getByRole } = render(<Item componentsProps={{ decorator: { component: 'div' } }} />);
133+
const { getByRole } = render(<Item slotProps={{ decorator: { component: 'div' } }} />);
134134
expect(getByRole('button').firstChild).to.have.tagName('div');
135135
});
136136
});
@@ -144,12 +144,12 @@ describe('useSlot', () => {
144144

145145
const Item = (props: {
146146
component?: React.ElementType;
147-
components?: {
147+
slots?: {
148148
root?: React.ElementType;
149149
listbox?: React.ElementType;
150150
option?: React.ElementType;
151151
};
152-
componentsProps?: {
152+
slotProps?: {
153153
root?: SlotComponentProps<'button', Record<string, any>, {}>;
154154
listbox?: SlotComponentProps<'span', Record<string, any>, {}>;
155155
option?: SlotComponentProps<'div', Record<string, any>, {}>;
@@ -208,19 +208,19 @@ describe('useSlot', () => {
208208
const Listbox = ({ component }: { component?: React.ElementType }) => (
209209
<ul data-component={component} />
210210
);
211-
const { getByRole } = render(<Item components={{ listbox: Listbox }} />);
211+
const { getByRole } = render(<Item slots={{ listbox: Listbox }} />);
212212
expect(getByRole('list')).toBeVisible();
213213
expect(getByRole('list')).not.to.have.attribute('class');
214214
expect(getByRole('list')).not.to.have.attribute('data-component');
215215
});
216216

217217
it('the listbox leaf component can be changed', () => {
218-
const { getByRole } = render(<Item componentsProps={{ listbox: { component: 'div' } }} />);
218+
const { getByRole } = render(<Item slotProps={{ listbox: { component: 'div' } }} />);
219219
expect(getByRole('menu')).to.have.tagName('div');
220220
});
221221

222222
it('the option leaf component can be changed', () => {
223-
const { getByRole } = render(<Item componentsProps={{ option: { component: 'div' } }} />);
223+
const { getByRole } = render(<Item slotProps={{ option: { component: 'div' } }} />);
224224
expect(getByRole('menuitem')).to.have.tagName('div');
225225
});
226226
});

0 commit comments

Comments
 (0)