import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' import { parseNamedExports, parseNamedExportSpecs, parseInlineNamedExports, resolveLocalExportPath, resolveNamedExportPath, } from '../../../scripts/extract-docs-exports' const tempDirs: string[] = [] function createTempDir(): string { const dir = mkdtempSync(join(tmpdir(), 'mint-docs-exports-')) tempDirs.push(dir) return dir } afterEach(() => { for (const dir of tempDirs.splice(0)) { rmSync(dir, { recursive: true, force: true }) } }) describe('extract docs export helpers', () => { it('parses aliased named export specs and skips invalid entries', () => { expect(parseNamedExportSpecs(` type LocalType as PublicType, InternalName as PublicName, default, invalid-name, // ignored `)).toEqual([ { localName: 'LocalType', exportedName: 'PublicType' }, { localName: 'InternalName', exportedName: 'PublicName' }, ]) }) it('resolves local export paths across files and directory indexes', () => { const dir = createTempDir() const indexPath = join(dir, 'index.ts') const featureDir = join(dir, 'feature') writeFileSync(indexPath, '') writeFileSync(join(dir, 'direct.ts'), 'export const Direct = 1') writeFileSync(join(dir, 'component.vue'), '