@@ -69,14 +69,6 @@ describe('typedUnion', () => {
69
69
BoxStruct ,
70
70
typedUnion ( [ TextStruct , FieldStruct ] ) ,
71
71
] ) ;
72
- const stringUnion = nullUnion ( [
73
- string ( ) ,
74
- typedUnion ( [ TextStruct , BoldStruct ] ) ,
75
- ] ) ;
76
- const nonTypedObjectUnion = nullUnion ( [
77
- typedUnion ( [ TextStruct , BoldStruct ] ) ,
78
- object ( { type : literal ( 'bar' ) } ) ,
79
- ] ) ;
80
72
81
73
it ( 'validates strictly the part of the union that matches the type' , ( ) => {
82
74
// @ts -expect-error Invalid props.
@@ -97,6 +89,11 @@ describe('typedUnion', () => {
97
89
} ) ;
98
90
99
91
it ( 'validates when nested in a union including primitives' , ( ) => {
92
+ const stringUnion = nullUnion ( [
93
+ string ( ) ,
94
+ typedUnion ( [ TextStruct , BoldStruct ] ) ,
95
+ ] ) ;
96
+
100
97
// @ts -expect-error Invalid props.
101
98
const result = validate ( Text ( { } ) , stringUnion ) ;
102
99
@@ -106,6 +103,11 @@ describe('typedUnion', () => {
106
103
} ) ;
107
104
108
105
it ( 'validates when nested in a union including non-typed objects' , ( ) => {
106
+ const nonTypedObjectUnion = nullUnion ( [
107
+ typedUnion ( [ TextStruct , BoldStruct ] ) ,
108
+ object ( { type : literal ( 'bar' ) } ) ,
109
+ ] ) ;
110
+
109
111
const result = validate ( { type : 'abc' } , nonTypedObjectUnion ) ;
110
112
111
113
expect ( result [ 0 ] ?. message ) . toBe (
0 commit comments