23 lines
659 B
TypeScript
23 lines
659 B
TypeScript
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
const rootDir = path.resolve(__dirname, '..', '..')
|
|
|
|
function collectRouteFiles(dir: string): string[] {
|
|
if (!fs.existsSync(dir)) return []
|
|
|
|
return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
const fullPath = path.join(dir, entry.name)
|
|
if (entry.isDirectory()) return collectRouteFiles(fullPath)
|
|
return entry.name === 'route.ts' ? [fullPath] : []
|
|
})
|
|
}
|
|
|
|
describe('生产路由边界', () => {
|
|
it('不应保留公开 debug API 路由', () => {
|
|
const debugRoutes = collectRouteFiles(path.join(rootDir, 'app', 'api', 'debug'))
|
|
|
|
expect(debugRoutes).toEqual([])
|
|
})
|
|
})
|