@@ -260,6 +260,65 @@ def fn():
260
260
} ) ;
261
261
} ) ;
262
262
263
+ describe ( 'with double quotes' , ( ) => {
264
+ it ( 'should extract an enum of the format "can be x"' , ( ) => {
265
+ const values = extractStringEnum ( `Can be "x"` ) ! ;
266
+ expect ( values ) . not . toBe ( null ) ;
267
+ expect ( values ) . toHaveLength ( 1 ) ;
268
+ expect ( values [ 0 ] . value ) . toBe ( 'x' ) ;
269
+ } ) ;
270
+
271
+ it ( 'should extract an enum of the format "can be x or y"' , ( ) => {
272
+ const values = extractStringEnum ( `Can be "x" or "y"` ) ! ;
273
+ expect ( values ) . not . toBe ( null ) ;
274
+ expect ( values ) . toHaveLength ( 2 ) ;
275
+ expect ( values [ 0 ] . value ) . toBe ( 'x' ) ;
276
+ expect ( values [ 1 ] . value ) . toBe ( 'y' ) ;
277
+ } ) ;
278
+
279
+ it ( 'should extract an enum of the format "can be x, y or z"' , ( ) => {
280
+ const values = extractStringEnum ( `Can be "x", "y" or "z"` ) ! ;
281
+ expect ( values ) . not . toBe ( null ) ;
282
+ expect ( values ) . toHaveLength ( 3 ) ;
283
+ expect ( values [ 0 ] . value ) . toBe ( 'x' ) ;
284
+ expect ( values [ 1 ] . value ) . toBe ( 'y' ) ;
285
+ expect ( values [ 2 ] . value ) . toBe ( 'z' ) ;
286
+ } ) ;
287
+
288
+ it ( 'should extract an enum of the format "can be x, y, or z"' , ( ) => {
289
+ const values = extractStringEnum ( `Can be "x", "y", or "z"` ) ! ;
290
+ expect ( values ) . not . toBe ( null ) ;
291
+ expect ( values ) . toHaveLength ( 3 ) ;
292
+ expect ( values [ 0 ] . value ) . toBe ( 'x' ) ;
293
+ expect ( values [ 1 ] . value ) . toBe ( 'y' ) ;
294
+ expect ( values [ 2 ] . value ) . toBe ( 'z' ) ;
295
+ } ) ;
296
+
297
+ it ( 'should extract an enum of the format "values include a' , ( ) => {
298
+ const values = extractStringEnum ( `Values include "a"` ) ! ;
299
+ expect ( values ) . not . toBe ( null ) ;
300
+ expect ( values ) . toHaveLength ( 1 ) ;
301
+ expect ( values [ 0 ] . value ) . toBe ( 'a' ) ;
302
+ } ) ;
303
+
304
+ it ( 'should extract an enum of the format "values include a and b' , ( ) => {
305
+ const values = extractStringEnum ( `Values include "a" and "b"` ) ! ;
306
+ expect ( values ) . not . toBe ( null ) ;
307
+ expect ( values ) . toHaveLength ( 2 ) ;
308
+ expect ( values [ 0 ] . value ) . toBe ( 'a' ) ;
309
+ expect ( values [ 1 ] . value ) . toBe ( 'b' ) ;
310
+ } ) ;
311
+
312
+ it ( 'should extract an enum of the format "values include a, b and c' , ( ) => {
313
+ const values = extractStringEnum ( `Values include "a", "b" and "c"` ) ! ;
314
+ expect ( values ) . not . toBe ( null ) ;
315
+ expect ( values ) . toHaveLength ( 3 ) ;
316
+ expect ( values [ 0 ] . value ) . toBe ( 'a' ) ;
317
+ expect ( values [ 1 ] . value ) . toBe ( 'b' ) ;
318
+ expect ( values [ 2 ] . value ) . toBe ( 'c' ) ;
319
+ } ) ;
320
+ } ) ;
321
+
263
322
describe ( 'rawTypeToTypeInformation()' , ( ) => {
264
323
it ( 'should map a primitive types correctly' , ( ) => {
265
324
expect ( rawTypeToTypeInformation ( 'Boolean' , '' , null ) ) . toMatchSnapshot ( ) ;
0 commit comments