import { test } from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { dirname, join } from 'node:path'; import { run } from './dist/main.js'; const here = dirname(fileURLToPath(import.meta.url)); test('declaration emit 生成 .d.ts 与声明映射', () => { const out = []; const ret = run((msg) => out.push(msg)); assert.deepEqual(ret, ['ADA']); assert.deepEqual(out, ret); const dts = readFileSync(join(here, 'dist', 'types', 'index.d.ts'), 'utf8'); assert.ok(dts.includes('export interface User'), '接口被导出'); assert.ok(dts.includes('export declare function displayName'), '函数声明被导出'); assert.ok(!dts.includes('return user.name.toUpperCase'), '声明文件不含实现'); });