import Action from '@/components/modal/actions/Action.vue'; import { mount } from '@vue/test-utils'; describe('Action tests', () => { it('should render as button', async () => { const props = { text: '', icon: '', variant: 'button' as 'button', onClick: vi.fn(), }; const wrapper = mount(Action, { props }); const button = wrapper.findComponentByTestId('button'); expect(button).toBeTruthy(); await button.trigger('click'); expect(props.onClick).toHaveBeenCalled(); }); it('should render as menu-item', async () => { const props = { text: '', icon: '', variant: 'menu-item' as 'menu-item', onClick: vi.fn(), }; const wrapper = mount(Action, { props }); const menuItem = wrapper.findComponentByTestId('menu-item'); expect(menuItem).toBeTruthy(); await menuItem.trigger('click'); expect(props.onClick).toHaveBeenCalled(); }); it('should render nothing', async () => { const props = { text: '', icon: '', variant: 'invalid' as any, onClick: vi.fn(), }; const wrapper = mount(Action, { props }); expect(wrapper.text()).toBe(''); }); });