@@ -190,4 +190,77 @@ describe('composition validation', () => {
190190 expect ( result . errors [ 0 ] . keyword ) . toBe ( 'enum' ) ;
191191 } ) ;
192192 } ) ;
193+
194+ describe ( 'oneOf with allOf branches (strict mode)' , ( ) => {
195+ it ( 'validates plan item without false positive' , ( ) => {
196+ const result = validator . validateRequest ( '/v1/cart-items' , 'post' , [
197+ {
198+ type : 'plan' ,
199+ value : {
200+ name : 'Unlimited Plan' ,
201+ sku : 'plan-unlimited' ,
202+ periodicity : 'monthly' ,
203+ metadata : { recurrence : 'monthly' } ,
204+ } ,
205+ } ,
206+ ] ) ;
207+ expect ( result . valid ) . toBe ( true ) ;
208+ expect ( result . errors ) . toHaveLength ( 0 ) ;
209+ } ) ;
210+
211+ it ( 'validates trip item without false positive' , ( ) => {
212+ const result = validator . validateRequest ( '/v1/cart-items' , 'post' , [
213+ {
214+ type : 'trip' ,
215+ value : {
216+ name : 'Spain' ,
217+ sku : 'trip-spain' ,
218+ days : 7 ,
219+ metadata : { days : 7 } ,
220+ } ,
221+ } ,
222+ ] ) ;
223+ expect ( result . valid ) . toBe ( true ) ;
224+ expect ( result . errors ) . toHaveLength ( 0 ) ;
225+ } ) ;
226+
227+ it ( 'validates credit-recharge item without false positive' , ( ) => {
228+ const result = validator . validateRequest ( '/v1/cart-items' , 'post' , [
229+ {
230+ type : 'credit-recharge' ,
231+ value : {
232+ name : 'Credit Recharge 500' ,
233+ sku : 'credit-recharge-500' ,
234+ } ,
235+ } ,
236+ ] ) ;
237+ expect ( result . valid ) . toBe ( true ) ;
238+ expect ( result . errors ) . toHaveLength ( 0 ) ;
239+ } ) ;
240+
241+ it ( 'validates mixed cart items without false positive' , ( ) => {
242+ const result = validator . validateRequest ( '/v1/cart-items' , 'post' , [
243+ {
244+ type : 'plan' ,
245+ value : {
246+ name : 'Unlimited Plan' ,
247+ sku : 'plan-unlimited' ,
248+ periodicity : 'monthly' ,
249+ metadata : { recurrence : 'monthly' } ,
250+ } ,
251+ } ,
252+ {
253+ type : 'trip' ,
254+ value : {
255+ name : 'Spain' ,
256+ sku : 'trip-spain' ,
257+ days : 7 ,
258+ metadata : { days : 7 } ,
259+ } ,
260+ } ,
261+ ] ) ;
262+ expect ( result . valid ) . toBe ( true ) ;
263+ expect ( result . errors ) . toHaveLength ( 0 ) ;
264+ } ) ;
265+ } ) ;
193266} ) ;
0 commit comments