@@ -20,6 +20,12 @@ import { WithinRangeIntegerTest } from "../../generated/testapi/WithinRangeInteg
20
20
import { WithinRangeNumberTest } from "../../generated/testapi/WithinRangeNumberTest" ;
21
21
import { WithinRangeStringTest } from "../../generated/testapi/WithinRangeStringTest" ;
22
22
23
+ import { DisabledUserTest } from "../../generated/testapi/DisabledUserTest" ;
24
+ import { DisjointUnionsUserTest } from "../../generated/testapi/DisjointUnionsUserTest" ;
25
+ import { EnabledUserTest } from "../../generated/testapi/EnabledUserTest" ;
26
+ import { EnumFalseTest } from "../../generated/testapi/EnumFalseTest" ;
27
+ import { EnumTrueTest } from "../../generated/testapi/EnumTrueTest" ;
28
+
23
29
const { generatedFilesDir, isSpecEnabled } = config . specs . testapi ;
24
30
25
31
// if there's no need for this suite in this particular run, just skip it
@@ -288,3 +294,84 @@ describe("WithinRangeStringTest defintion", () => {
288
294
}
289
295
) ;
290
296
} ) ;
297
+
298
+ describe ( "EnumTrueTest definition" , ( ) => {
299
+ const statusOk = { flag : true } ;
300
+ const statusKo = { flag : false } ;
301
+
302
+ it ( "should decode statusOk with EnumTrueTest" , ( ) => {
303
+ const result = EnumTrueTest . decode ( statusOk ) ;
304
+ expect ( result . isRight ( ) ) . toBe ( true ) ;
305
+ } ) ;
306
+
307
+ it ( "should not decode statusKo with EnumTrueTest" , ( ) => {
308
+ const result = EnumTrueTest . decode ( statusKo ) ;
309
+
310
+ expect ( result . isLeft ( ) ) . toBe ( true ) ;
311
+ } ) ;
312
+ } ) ;
313
+
314
+ describe ( "EnumFalseTest definition" , ( ) => {
315
+ const statusOk = { flag : false } ;
316
+ const statusKo = { flag : true } ;
317
+
318
+ it ( "should decode statusOk with EnumFalseTest" , ( ) => {
319
+ const result = EnumFalseTest . decode ( statusOk ) ;
320
+ expect ( result . isRight ( ) ) . toBe ( true ) ;
321
+ } ) ;
322
+
323
+ it ( "should not decode statusKo with EnumFalseTest" , ( ) => {
324
+ const result = EnumFalseTest . decode ( statusKo ) ;
325
+
326
+ expect ( result . isLeft ( ) ) . toBe ( true ) ;
327
+ } ) ;
328
+ } ) ;
329
+
330
+ describe ( "DisjointUnionsUserTest definition" , ( ) => {
331
+ const enabledUser = {
332
+ description : "Description for the user" ,
333
+ enabled : true ,
334
+ username : "user"
335
+ } ;
336
+ const disabledUser = {
337
+ enabled : false ,
338
+ reason : "reason for the user" ,
339
+ username : "user"
340
+ } ;
341
+
342
+ const invalidUser = {
343
+ description : "Description for the user" ,
344
+ enabled : false ,
345
+ username : "user"
346
+ } ;
347
+
348
+ it ( "should decode enabledUser with DisjointUnionsUserTest" , ( ) => {
349
+ const userTest = DisjointUnionsUserTest . decode ( enabledUser ) ;
350
+ const enabledUserTest = EnabledUserTest . decode ( enabledUser ) ;
351
+ const disabledUserTest = DisabledUserTest . decode ( enabledUser ) ;
352
+
353
+ expect ( userTest . isRight ( ) ) . toBe ( true ) ;
354
+ expect ( enabledUserTest . isRight ( ) ) . toBe ( true ) ;
355
+ expect ( disabledUserTest . isLeft ( ) ) . toBe ( true ) ;
356
+ } ) ;
357
+
358
+ it ( "should decode disabledUser with DisjointUnionsUserTest" , ( ) => {
359
+ const userTest = DisjointUnionsUserTest . decode ( disabledUser ) ;
360
+ const enabledUserTest = EnabledUserTest . decode ( disabledUser ) ;
361
+ const disabledUserTest = DisabledUserTest . decode ( disabledUser ) ;
362
+
363
+ expect ( userTest . isRight ( ) ) . toBe ( true ) ;
364
+ expect ( disabledUserTest . isRight ( ) ) . toBe ( true ) ;
365
+ expect ( enabledUserTest . isLeft ( ) ) . toBe ( true ) ;
366
+ } ) ;
367
+
368
+ it ( "should not decode invalidUser with DisjointUnionsUserTest" , ( ) => {
369
+ const userTest = DisjointUnionsUserTest . decode ( invalidUser ) ;
370
+ const enabledUserTest = EnabledUserTest . decode ( invalidUser ) ;
371
+ const disabledUserTest = DisabledUserTest . decode ( invalidUser ) ;
372
+
373
+ expect ( userTest . isLeft ( ) ) . toBe ( true ) ;
374
+ expect ( disabledUserTest . isLeft ( ) ) . toBe ( true ) ;
375
+ expect ( enabledUserTest . isLeft ( ) ) . toBe ( true ) ;
376
+ } ) ;
377
+ } ) ;
0 commit comments