@@ -6,8 +6,8 @@ import { generate } from '../src/generator'
6
6
7
7
describe ( 'dts-generation' , ( ) => {
8
8
const testDir = join ( __dirname , 'fixtures' )
9
- const inputDir = join ( testDir , 'input' , 'example' )
10
- const outputDir = join ( testDir , 'output' , 'example' )
9
+ const inputDir = join ( testDir , 'input' )
10
+ const outputDir = join ( testDir , 'output' )
11
11
const generatedDir = join ( testDir , 'generated' )
12
12
13
13
// List of all example files to test
@@ -25,11 +25,27 @@ describe('dts-generation', () => {
25
25
'0011'
26
26
]
27
27
28
+ // List of all fixture files to test (excluding checker.ts which is too large)
29
+ const fixtures = [
30
+ 'class' ,
31
+ 'edge-cases' ,
32
+ 'enum' ,
33
+ 'exports' ,
34
+ 'function' ,
35
+ 'function-types' ,
36
+ 'imports' ,
37
+ 'interface' ,
38
+ 'module' ,
39
+ 'namespace' ,
40
+ 'type' ,
41
+ 'variable'
42
+ ]
43
+
28
44
// Generate a test for each example file
29
45
examples . forEach ( ( example ) => {
30
46
it ( `should properly generate types for example ${ example } ` , async ( ) => {
31
47
const config : DtsGenerationOption = {
32
- entrypoints : [ join ( inputDir , `${ example } .ts` ) ] ,
48
+ entrypoints : [ join ( inputDir , 'example' , `${ example } .ts` ) ] ,
33
49
outdir : generatedDir ,
34
50
clean : false ,
35
51
tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
@@ -38,7 +54,7 @@ describe('dts-generation', () => {
38
54
39
55
await generate ( config )
40
56
41
- const outputPath = join ( outputDir , `${ example } .d.ts` )
57
+ const outputPath = join ( outputDir , 'example' , `${ example } .d.ts` )
42
58
const generatedPath = join ( generatedDir , `${ example } .d.ts` )
43
59
44
60
const expectedContent = await Bun . file ( outputPath ) . text ( )
@@ -48,6 +64,29 @@ describe('dts-generation', () => {
48
64
} )
49
65
} )
50
66
67
+ // Generate a test for each fixture file
68
+ fixtures . forEach ( ( fixture ) => {
69
+ it ( `should properly generate types for fixture ${ fixture } ` , async ( ) => {
70
+ const config : DtsGenerationOption = {
71
+ entrypoints : [ join ( inputDir , `${ fixture } .ts` ) ] ,
72
+ outdir : generatedDir ,
73
+ clean : false ,
74
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
75
+ outputStructure : 'flat' ,
76
+ }
77
+
78
+ await generate ( config )
79
+
80
+ const outputPath = join ( outputDir , `${ fixture } .d.ts` )
81
+ const generatedPath = join ( generatedDir , `${ fixture } .d.ts` )
82
+
83
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
84
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
85
+
86
+ expect ( generatedContent ) . toBe ( expectedContent )
87
+ } )
88
+ } )
89
+
51
90
afterEach ( async ( ) => {
52
91
// Clean up generated files
53
92
try {
0 commit comments