import '@testing-library/jest-dom' import { render, screen, waitFor } from '../../utils/test-utils' import { PktIcon } from './Icon' declare global { interface Window { pktFetch: () => Promise<{ ok: boolean; text: () => Promise }> pktIconPath: string } } describe('PktIcon', () => { window.pktFetch = (file = 'filnavn.svg') => Promise.resolve({ ok: true, text: () => Promise.resolve(`Her er SVGen`), }) window.pktIconPath = 'sti' describe('with default fetcher', () => { test('fetches SVG with default fetcher', async () => { await render() await window.customElements.whenDefined('pkt-icon') const icon = await screen.findByRole('img') expect(icon).toMatchInlineSnapshot(` Her er SVGen `) }) test('fetches SVG', async () => { const { container } = await render(
, ) await window.customElements.whenDefined('pkt-icon') await waitFor(async () => { const icons = await screen.findAllByTestId('icon') expect(icons).toHaveLength(3) }) }) }) })