// 通用信息弹窗(docs/32 文件关联引导用):标题/正文渲染,点「知道了」关闭。 import { describe, it, expect, vi } from 'vitest' import { createRoot } from 'react-dom/client' import { act } from 'react-dom/test-utils' import { InfoModal } from '../src/components/Modals' describe('InfoModal', () => { it('渲染标题与正文,点知道了回调关闭', async () => { const container = document.createElement('div') document.body.appendChild(container) const root = createRoot(container) const onClose = vi.fn() await act(async () => { root.render() }) expect(container.textContent).toContain('文件关联') expect(container.textContent).toContain('已注册为候选打开方式。') const btn = [...container.querySelectorAll('button')].find((b) => b.textContent === '知道了')! await act(async () => { btn.dispatchEvent(new MouseEvent('click', { bubbles: true })) }) expect(onClose).toHaveBeenCalledTimes(1) await act(async () => { root.unmount() }) container.remove() }) })