File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,37 @@ describe('TypeScript File Generation', () => {
161
161
) ;
162
162
} ) ;
163
163
164
+ it ( 'uses single quotes in enum values' , async ( ) => {
165
+ await withTempFiles (
166
+ {
167
+ '.app-config.meta.json5' : `{
168
+ generate: [{ file: "generated.d.ts" }]
169
+ }` ,
170
+ '.app-config.schema.yaml' : `
171
+ type: object
172
+ additionalProperties: false
173
+
174
+ properties:
175
+ commit:
176
+ type: string
177
+ enum:
178
+ - foo
179
+ - foo-bar
180
+ ` ,
181
+ } ,
182
+ async ( dir ) => {
183
+ const output = await generateTypeFiles ( { directory : dir ( '.' ) } ) ;
184
+
185
+ expect ( output . length ) . toBe ( 1 ) ;
186
+
187
+ const config = await readFile ( dir ( 'generated.d.ts' ) ) . then ( ( v ) => v . toString ( ) ) ;
188
+
189
+ expect ( config ) . toMatch ( `Foo = 'foo'` ) ;
190
+ expect ( config ) . toMatch ( `FooBar = 'foo-bar'` ) ;
191
+ } ,
192
+ ) ;
193
+ } ) ;
194
+
164
195
it ( 'creates an empty interface for config' , async ( ) => {
165
196
await withTempFiles (
166
197
{
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ export async function generateQuicktype(
137
137
// this is a fix for quicktype, which adds an Object postfix, sometimes
138
138
. map ( ( line ) => line . replace ( `interface ${ name } Object` , `interface ${ name } ` ) )
139
139
. map ( ( line ) => line . replace ( / : + D a t e / g, `: string` ) )
140
+ . map ( ( line ) => line . replace ( / = " ( [ \w - ] + ) " / g, `= '$1'` ) )
140
141
. map ( ( line ) => line . replace ( / : + ( \w ) / g, ': $1' ) )
141
142
) ;
142
143
}
You can’t perform that action at this time.
0 commit comments