import { render, screen, within } from '@testing-library/react' import React from 'react' import ContactUs from '../ContactUs' jest.mock( '@woocommerce/settings', () => ({ getAdminLink: (path: string) => `/wp-admin/${path}` }), { virtual: true } ) jest.mock('../../components/FeedbackForm', () => ({ __esModule: true, default: () =>
feedback form
, })) const contact = (title: string) => screen.getByRole('heading', { name: title }).closest('li') as HTMLElement describe('ContactUs', () => { it('lets the merchant reach the checkout team', () => { render() const checkoutTeam = contact('Checkout team') expect( within(checkoutTeam).getByText( 'Help with setting up the plugin, delivery options and the checkout in general.' ) ).toBeInTheDocument() expect( within(checkoutTeam).getByRole('link', { name: 'Frequently asked questions', }) ).toHaveAttribute( 'href', '/wp-admin/admin.php?page=wc-admin&path=/posten-bring-checkout/faq' ) expect( within(checkoutTeam).getByRole('link', { name: 'checkout.implementering@posten.no', }) ).toHaveAttribute('href', 'mailto:checkout.implementering@posten.no') expect(within(checkoutTeam).getByText('feedback form')).toBeInTheDocument() }) it('lets the merchant reach customer service', () => { render() const customerService = contact('Customer service') expect( within(customerService).getByText( 'Questions about deliveries, invoices and your Mybring account.' ) ).toBeInTheDocument() const createCase = within(customerService).getByRole('link', { name: 'Create a case in Mybring', }) expect(createCase).toHaveAttribute( 'href', 'https://www.mybring.com/support/cases' ) expect(createCase).toHaveAttribute('target', '_blank') }) it('lets the merchant call customer service', () => { render() expect( within(contact('Customer service')).getByRole('link', { name: '+47 22030045', }) ).toHaveAttribute('href', 'tel:+4722030045') }) it('marks the phone number with a phone icon that screen readers skip', () => { render() const call = within(contact('Customer service')).getByRole('link', { name: '+47 22030045', }) expect(call.querySelector('svg')).toHaveAttribute('aria-hidden', 'true') }) })