Skip to content

Commit 91e9e00

Browse files
committed
chore(@clayui/drop-down): LPD-71044 Add test for title should work in ITEMS
1 parent 93e1fba commit 91e9e00

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

packages/clay-drop-down/src/__tests__/DropDownWithItems.tsx

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import {ClayDropDownWithItems} from '..';
77
import ClayButton from '@clayui/button';
8-
import {cleanup, render} from '@testing-library/react';
8+
import {cleanup, fireEvent, render, screen} from '@testing-library/react';
99
import React from 'react';
1010

1111
const spritemap = 'icons.svg';
@@ -178,4 +178,59 @@ describe('ClayDropDownWithItems', () => {
178178

179179
expect(document.body).toMatchSnapshot();
180180
});
181+
182+
it('renders a DropDownWithItems using title', () => {
183+
render(
184+
<ClayDropDownWithItems
185+
items={[
186+
{
187+
href: '#',
188+
title: 'linkable',
189+
},
190+
{
191+
items: [
192+
{
193+
checked: true,
194+
title: 'checkbox',
195+
type: 'checkbox' as const,
196+
},
197+
{
198+
checked: false,
199+
title: 'checkbox 1',
200+
type: 'checkbox' as const,
201+
},
202+
],
203+
title: 'checkbox',
204+
type: 'group' as const,
205+
},
206+
{
207+
items: [
208+
{
209+
title: 'one',
210+
type: 'radio' as const,
211+
value: 'one',
212+
},
213+
{
214+
title: 'two',
215+
type: 'radio' as const,
216+
value: 'two',
217+
},
218+
],
219+
name: 'radio',
220+
title: 'radio',
221+
type: 'radiogroup' as const,
222+
},
223+
]}
224+
renderMenuOnClick
225+
spritemap={spritemap}
226+
trigger={<ClayButton>Click Me</ClayButton>}
227+
/>
228+
);
229+
230+
const toggleButton = document.querySelector('.dropdown-toggle');
231+
232+
fireEvent.click(toggleButton as HTMLButtonElement, {});
233+
234+
expect(screen.getByText('linkable')).toBeDefined();
235+
});
181236
});

0 commit comments

Comments
 (0)