import { Window } from 'happy-dom'; import { afterEach, describe, expect, it, vi } from 'vitest'; describe('@videojs/html/icons', () => { afterEach(() => { vi.unstubAllGlobals(); vi.resetModules(); }); it('exports SVG strings without registering media-icon', async () => { const testWindow = new Window(); vi.stubGlobal('window', testWindow); vi.stubGlobal('document', testWindow.document); vi.stubGlobal('customElements', testWindow.customElements); vi.stubGlobal('HTMLElement', testWindow.HTMLElement); const { playIcon } = await import('../index'); expect(playIcon).toContain(' { const testWindow = new Window(); vi.stubGlobal('window', testWindow); vi.stubGlobal('document', testWindow.document); vi.stubGlobal('customElements', testWindow.customElements); vi.stubGlobal('HTMLElement', testWindow.HTMLElement); document.body.innerHTML = ''; await import('../element'); await customElements.whenDefined('media-icon'); await vi.waitFor(() => { expect(document.querySelector('media-icon')?.innerHTML).toContain(' { const testWindow = new Window(); vi.stubGlobal('window', testWindow); vi.stubGlobal('document', testWindow.document); vi.stubGlobal('customElements', testWindow.customElements); vi.stubGlobal('HTMLElement', testWindow.HTMLElement); document.body.innerHTML = ''; await import('../element'); await customElements.whenDefined('media-icon'); await vi.waitFor(() => { expect(document.querySelector('media-icon')?.innerHTML).toContain(' { const testWindow = new Window(); vi.stubGlobal('window', testWindow); vi.stubGlobal('document', testWindow.document); vi.stubGlobal('customElements', testWindow.customElements); vi.stubGlobal('HTMLElement', testWindow.HTMLElement); document.body.innerHTML = ` `; await import('../element'); await customElements.whenDefined('media-icon'); await vi.waitFor(() => { expect(document.querySelector('#good')?.innerHTML).toContain(' { const testWindow = new Window(); vi.stubGlobal('window', testWindow); vi.stubGlobal('document', testWindow.document); vi.stubGlobal('customElements', testWindow.customElements); vi.stubGlobal('HTMLElement', testWindow.HTMLElement); document.body.innerHTML = ''; await import('../element'); await customElements.whenDefined('media-icon'); await Promise.resolve(); await Promise.resolve(); expect(document.querySelector('media-icon')?.innerHTML).toBe(''); }); it('renders icons from a family-specific import', async () => { const testWindow = new Window(); vi.stubGlobal('window', testWindow); vi.stubGlobal('document', testWindow.document); vi.stubGlobal('customElements', testWindow.customElements); vi.stubGlobal('HTMLElement', testWindow.HTMLElement); document.body.innerHTML = ''; await import('../element/minimal'); await customElements.whenDefined('media-icon'); expect(document.querySelector('media-icon')?.innerHTML).toContain('