-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathdropdownActions.spec.tsx
41 lines (36 loc) · 1.11 KB
/
dropdownActions.spec.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
import DropdownActions from './dropdownActions';
describe('DropdownActions', () => {
it('selecting actions calls onAction', async () => {
const cb = jest.fn();
render(
<DropdownActions
label="Trigger"
actions={[
{
disabled: false,
key: 'first',
name: 'Option',
onAction: cb,
skipConfirmModal: true,
},
]}
/>
);
await userEvent.click(screen.getByText('Trigger'));
await userEvent.click(screen.getByText('Option'));
expect(screen.queryByTestId('disabled-icon')).not.toBeInTheDocument();
expect(cb).toHaveBeenCalled();
});
it('disabled actions have an icon', async () => {
const cb = jest.fn();
render(
<DropdownActions
label="Trigger"
actions={[{disabled: true, key: 'first', name: 'Disabled Option', onAction: cb}]}
/>
);
await userEvent.click(screen.getByText('Trigger'));
expect(await screen.findByTestId('disabled-icon')).toBeInTheDocument();
});
});