@@ -35,6 +35,7 @@ describeAllImplementations((implementation) => {
35
35
updateStaleOnly : false ,
36
36
logLevel : "verbose" ,
37
37
outputFolder : null ,
38
+ allowArbitraryExtensions : false ,
38
39
} ) ;
39
40
40
41
const expectedPath = path . join (
@@ -51,6 +52,40 @@ describeAllImplementations((implementation) => {
51
52
) ;
52
53
} ) ;
53
54
55
+ it ( "writes the corresponding type definitions for a file and logs when allowArbitraryExtensions is set" , async ( ) => {
56
+ const testFile = path . resolve ( __dirname , ".." , "dummy-styles/style.scss" ) ;
57
+
58
+ await writeFile ( testFile , {
59
+ banner : "" ,
60
+ watch : false ,
61
+ ignoreInitial : false ,
62
+ exportType : "named" ,
63
+ exportTypeName : "ClassNames" ,
64
+ exportTypeInterface : "Styles" ,
65
+ listDifferent : false ,
66
+ ignore : [ ] ,
67
+ implementation,
68
+ quoteType : "single" ,
69
+ updateStaleOnly : false ,
70
+ logLevel : "verbose" ,
71
+ outputFolder : null ,
72
+ allowArbitraryExtensions : true ,
73
+ } ) ;
74
+
75
+ const expectedPath = path . join (
76
+ process . cwd ( ) ,
77
+ "__tests__/dummy-styles/style.d.scss.ts"
78
+ ) ;
79
+
80
+ expect ( fs . writeFileSync ) . toHaveBeenCalledWith (
81
+ expectedPath ,
82
+ "export declare const someClass: string;\n"
83
+ ) ;
84
+ expect ( console . log ) . toHaveBeenCalledWith (
85
+ expect . stringContaining ( `[GENERATED TYPES] ${ expectedPath } ` )
86
+ ) ;
87
+ } ) ;
88
+
54
89
it ( "skips files with no classes" , async ( ) => {
55
90
const testFile = path . resolve ( __dirname , ".." , "dummy-styles/empty.scss" ) ;
56
91
@@ -68,6 +103,7 @@ describeAllImplementations((implementation) => {
68
103
updateStaleOnly : false ,
69
104
logLevel : "verbose" ,
70
105
outputFolder : null ,
106
+ allowArbitraryExtensions : false ,
71
107
} ) ;
72
108
73
109
expect ( fs . writeFileSync ) . not . toHaveBeenCalled ( ) ;
@@ -111,6 +147,7 @@ describeAllImplementations((implementation) => {
111
147
updateStaleOnly : false ,
112
148
logLevel : "verbose" ,
113
149
outputFolder : null ,
150
+ allowArbitraryExtensions : false ,
114
151
} ) ;
115
152
116
153
expect ( fs . unlinkSync ) . toHaveBeenCalledWith ( existingTypes ) ;
@@ -142,6 +179,7 @@ describeAllImplementations((implementation) => {
142
179
updateStaleOnly : false ,
143
180
logLevel : "verbose" ,
144
181
outputFolder : "__generated__" ,
182
+ allowArbitraryExtensions : false ,
145
183
} ) ;
146
184
147
185
const expectedPath = path . join (
@@ -200,6 +238,7 @@ describeAllImplementations((implementation) => {
200
238
updateStaleOnly : true ,
201
239
logLevel : "verbose" ,
202
240
outputFolder : null ,
241
+ allowArbitraryExtensions : false ,
203
242
} ) ;
204
243
205
244
expect ( fs . writeFileSync ) . not . toHaveBeenCalled ( ) ;
@@ -235,6 +274,7 @@ describeAllImplementations((implementation) => {
235
274
updateStaleOnly : true ,
236
275
logLevel : "verbose" ,
237
276
outputFolder : null ,
277
+ allowArbitraryExtensions : false ,
238
278
} ) ;
239
279
240
280
expect ( fs . writeFileSync ) . toHaveBeenCalled ( ) ;
@@ -259,6 +299,7 @@ describeAllImplementations((implementation) => {
259
299
updateStaleOnly : true ,
260
300
logLevel : "verbose" ,
261
301
outputFolder : null ,
302
+ allowArbitraryExtensions : false ,
262
303
} ) ;
263
304
264
305
expect ( fs . writeFileSync ) . not . toHaveBeenCalled ( ) ;
@@ -281,6 +322,7 @@ describeAllImplementations((implementation) => {
281
322
updateStaleOnly : true ,
282
323
logLevel : "verbose" ,
283
324
outputFolder : null ,
325
+ allowArbitraryExtensions : false ,
284
326
} ) ;
285
327
286
328
expect ( fs . statSync ) . not . toHaveBeenCalledWith ( testFile ) ;
0 commit comments