import { render, fireEvent, waitFor } from '@@/test/kalimotxo-test-utils' import PrivacyModal from './PrivacyModal.vue' describe('PrivacyModal', () => { test('shows modal content on clicking trigger element', async () => { const { findByText, openModal } = renderComponent() await openModal() expect( await findByText('Información básica sobre Protección de Datos'), ).toBeInTheDocument() }) test('hides modal content on clicking close element', async () => { const { findByText, queryByText, openModal, closeModal } = renderComponent() await openModal() expect(await findByText('HOLALUZ-CLIDOM, S.A.')).toBeInTheDocument() await closeModal() await waitFor(() => expect( queryByText('Información básica sobre Protección de Datos'), ).not.toBeInTheDocument(), ) }) }) function renderComponent() { const utils = render(PrivacyModal, { scopedSlots: { default: `open modal`, }, }) const openModal = () => fireEvent.click(utils.getByText('open modal')) const closeModal = () => fireEvent.click(utils.getByText('Entendido')) return { ...utils, openModal, closeModal } }