import { beforeEach, describe, expect, it } from 'vitest' import { mount } from '@vue/test-utils' import OrderAccessInfo from '@/components/order/OrderAccessInfo.vue' import vuetify from '@/plugins/vuetify' function mountAccessInfo (code) { return mount(OrderAccessInfo, { props: { code }, global: { plugins: [vuetify] }, }) } describe('OrderAccessInfo', () => { beforeEach(() => { navigator.clipboard.writeText.mockClear() }) it('muestra el código del pedido', () => { const wrapper = mountAccessInfo('abc123') expect(wrapper.text()).toContain('abc123') }) it('muestra el link público construido con el código', () => { const wrapper = mountAccessInfo('abc123') expect(wrapper.text()).toContain( `${window.location.origin}/pedido/abc123` ) }) it('copia el link al presionar el botón de copiar link', async () => { const wrapper = mountAccessInfo('abc123') await wrapper.find('[data-test="copy-link"]').trigger('click') expect(navigator.clipboard.writeText).toHaveBeenCalledWith( `${window.location.origin}/pedido/abc123` ) }) it('copia el código al presionar el botón de copiar código', async () => { const wrapper = mountAccessInfo('abc123') await wrapper.find('[data-test="copy-code"]').trigger('click') expect(navigator.clipboard.writeText).toHaveBeenCalledWith('abc123') }) })