@@ -31,6 +31,195 @@ describe('dts-generation', () => {
31
31
expect ( generatedContent ) . toBe ( expectedContent )
32
32
} )
33
33
34
+ it ( 'should properly generate types for class example' , async ( ) => {
35
+ const example = 'class'
36
+
37
+ const config : DtsGenerationOption = {
38
+ entrypoints : [ join ( inputDir , `${ example } .ts` ) ] ,
39
+ outdir : generatedDir ,
40
+ clean : false ,
41
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
42
+ }
43
+
44
+ await generate ( config )
45
+
46
+ const outputPath = join ( outputDir , `${ example } .d.ts` )
47
+ const generatedPath = join ( generatedDir , `${ example } .d.ts` )
48
+
49
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
50
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
51
+
52
+ expect ( generatedContent ) . toBe ( expectedContent )
53
+ } )
54
+
55
+ it ( 'should properly generate types for enum example' , async ( ) => {
56
+ const example = 'enum'
57
+
58
+ const config : DtsGenerationOption = {
59
+ entrypoints : [ join ( inputDir , `${ example } .ts` ) ] ,
60
+ outdir : generatedDir ,
61
+ clean : false ,
62
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
63
+ }
64
+
65
+ await generate ( config )
66
+
67
+ const outputPath = join ( outputDir , `${ example } .d.ts` )
68
+ const generatedPath = join ( generatedDir , `${ example } .d.ts` )
69
+
70
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
71
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
72
+
73
+ expect ( generatedContent ) . toBe ( expectedContent )
74
+ } )
75
+
76
+ it ( 'should properly generate types for exports example' , async ( ) => {
77
+ const example = 'exports'
78
+
79
+ const config : DtsGenerationOption = {
80
+ entrypoints : [ join ( inputDir , `${ example } .ts` ) ] ,
81
+ outdir : generatedDir ,
82
+ clean : false ,
83
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
84
+ }
85
+
86
+ await generate ( config )
87
+
88
+ const outputPath = join ( outputDir , `${ example } .d.ts` )
89
+ const generatedPath = join ( generatedDir , `${ example } .d.ts` )
90
+
91
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
92
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
93
+
94
+ expect ( generatedContent ) . toBe ( expectedContent )
95
+ } )
96
+
97
+ it ( 'should properly generate types for function example' , async ( ) => {
98
+ const example = 'function'
99
+
100
+ const config : DtsGenerationOption = {
101
+ entrypoints : [ join ( inputDir , `${ example } .ts` ) ] ,
102
+ outdir : generatedDir ,
103
+ clean : false ,
104
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
105
+ }
106
+
107
+ await generate ( config )
108
+
109
+ const outputPath = join ( outputDir , `${ example } .d.ts` )
110
+ const generatedPath = join ( generatedDir , `${ example } .d.ts` )
111
+
112
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
113
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
114
+
115
+ expect ( generatedContent ) . toBe ( expectedContent )
116
+ } )
117
+
118
+ it ( 'should properly generate types for interface example' , async ( ) => {
119
+ const example = 'interface'
120
+
121
+ const config : DtsGenerationOption = {
122
+ entrypoints : [ join ( inputDir , `${ example } .ts` ) ] ,
123
+ outdir : generatedDir ,
124
+ clean : false ,
125
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
126
+ }
127
+
128
+ await generate ( config )
129
+
130
+ const outputPath = join ( outputDir , `${ example } .d.ts` )
131
+ const generatedPath = join ( generatedDir , `${ example } .d.ts` )
132
+
133
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
134
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
135
+
136
+ expect ( generatedContent ) . toBe ( expectedContent )
137
+ } )
138
+
139
+ it ( 'should properly generate types for type example' , async ( ) => {
140
+ const example = 'type'
141
+
142
+ const config : DtsGenerationOption = {
143
+ entrypoints : [ join ( inputDir , `${ example } .ts` ) ] ,
144
+ outdir : generatedDir ,
145
+ clean : false ,
146
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
147
+ }
148
+
149
+ await generate ( config )
150
+
151
+ const outputPath = join ( outputDir , `${ example } .d.ts` )
152
+ const generatedPath = join ( generatedDir , `${ example } .d.ts` )
153
+
154
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
155
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
156
+
157
+ expect ( generatedContent ) . toBe ( expectedContent )
158
+ } )
159
+
160
+ it ( 'should properly generate types for type example/0001' , async ( ) => {
161
+ const example = '0001'
162
+
163
+ const config : DtsGenerationOption = {
164
+ entrypoints : [ join ( inputDir , `example/${ example } .ts` ) ] ,
165
+ outdir : generatedDir ,
166
+ clean : false ,
167
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
168
+ }
169
+
170
+ await generate ( config )
171
+
172
+ const outputPath = join ( outputDir , `${ example } .d.ts` )
173
+ const generatedPath = join ( generatedDir , `${ example } .d.ts` )
174
+
175
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
176
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
177
+
178
+ expect ( generatedContent ) . toBe ( expectedContent )
179
+ } )
180
+
181
+ it ( 'should properly generate types for type example/0002' , async ( ) => {
182
+ const example = '0002'
183
+
184
+ const config : DtsGenerationOption = {
185
+ entrypoints : [ join ( inputDir , `example/${ example } .ts` ) ] ,
186
+ outdir : generatedDir ,
187
+ clean : false ,
188
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
189
+ }
190
+
191
+ await generate ( config )
192
+
193
+ const outputPath = join ( outputDir , `${ example } .d.ts` )
194
+ const generatedPath = join ( generatedDir , `${ example } .d.ts` )
195
+
196
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
197
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
198
+
199
+ expect ( generatedContent ) . toBe ( expectedContent )
200
+ } )
201
+
202
+ it ( 'should properly generate types for type example/0003' , async ( ) => {
203
+ const example = '0003'
204
+
205
+ const config : DtsGenerationOption = {
206
+ entrypoints : [ join ( inputDir , `example/${ example } .ts` ) ] ,
207
+ outdir : generatedDir ,
208
+ clean : false ,
209
+ tsconfigPath : join ( __dirname , '..' , 'tsconfig.json' ) ,
210
+ }
211
+
212
+ await generate ( config )
213
+
214
+ const outputPath = join ( outputDir , `${ example } .d.ts` )
215
+ const generatedPath = join ( generatedDir , `${ example } .d.ts` )
216
+
217
+ const expectedContent = await Bun . file ( outputPath ) . text ( )
218
+ const generatedContent = await Bun . file ( generatedPath ) . text ( )
219
+
220
+ expect ( generatedContent ) . toBe ( expectedContent )
221
+ } )
222
+
34
223
afterEach ( async ( ) => {
35
224
// Clean up generated files
36
225
try {
0 commit comments