(paths: string[], readSource?: SourceReader)
| 9 | const cleanups: (() => Promise<void>)[] = []; |
| 10 | afterEach(async () => { for (const cleanup of cleanups.splice(0)) await cleanup(); }); |
| 11 | async function mount(paths: string[], readSource?: SourceReader) { |
| 12 | const container = document.createElement('div'); document.body.append(container); |
| 13 | const root = createRoot(container); |
| 14 | let result: ReturnType<typeof useRepositoryGuide>; |
| 15 | function Harness({ paths, reader }: { paths: string[]; reader?: SourceReader }) { |
| 16 | result = useRepositoryGuide(paths, reader); return null; |
| 17 | } |
| 18 | const render = async (nextPaths = paths, reader = readSource) => { |
| 19 | await act(async () => root.render(<Harness paths={nextPaths} reader={reader} />)); |
| 20 | }; |
| 21 | cleanups.push(async () => { await act(async () => root.unmount()); container.remove(); }); |
| 22 | await render(); |
| 23 | return { render, result: () => result! }; |
| 24 | } |
| 25 | |
| 26 | it('finishes an empty inspection without leaving a permanent loading state', async () => { |
| 27 | const read = vi.fn(async () => ({ source: '' })); |
no test coverage detected