@@ -587,6 +587,58 @@ describe("object.refine", () => {
587587 } ) ;
588588} ) ;
589589
590+ describe ( "object.query" , ( ) => {
591+ const groupItem = s . object ( {
592+ id : s . string ( ) . flags ( { internal : true } ) ,
593+ value : s . string ( ) ,
594+ } ) ;
595+ it ( "omit internal with nullable array" , ( ) => {
596+ const o = s . object ( {
597+ groups : s . array ( groupItem ) . nullable ( ) ,
598+ } ) ;
599+ const o2 = o . query ( { internal : false } ) ;
600+ const o2Flags = o2 . props . groups . flagsValue ;
601+ const props = o2 . props . groups . items . props ;
602+ type names = keyof typeof props ;
603+ expectTypeOf < names > ( ) . toEqualTypeOf < "value" > ( ) ;
604+ expectTypeOf < typeof o2Flags > ( ) . toEqualTypeOf < {
605+ nullable : true ;
606+ } > ( ) ;
607+ expect ( o2Flags . nullable ) . toBe ( true ) ;
608+ expect ( Object . keys ( props ) ) . toEqual ( [ "value" ] ) ;
609+ } ) ;
610+ it ( "omit internal with optional array" , ( ) => {
611+ const o = s . object ( {
612+ groups : s . array ( groupItem ) . optional ( ) ,
613+ } ) ;
614+ const o2 = o . query ( { internal : false } ) ;
615+ const o2Flags = o2 . props . groups . flagsValue ;
616+ const props = o2 . props . groups . items . props ;
617+ type names = keyof typeof props ;
618+ expectTypeOf < names > ( ) . toEqualTypeOf < "value" > ( ) ;
619+ expectTypeOf < typeof o2Flags > ( ) . toEqualTypeOf < {
620+ optional : true ;
621+ } > ( ) ;
622+ expect ( o2Flags . optional ) . toBe ( true ) ;
623+ expect ( Object . keys ( props ) ) . toEqual ( [ "value" ] ) ;
624+ } ) ;
625+ it ( "omit internal with nullable object" , ( ) => {
626+ const o = s . object ( {
627+ groups : groupItem . nullable ( ) ,
628+ } ) ;
629+ const o2 = o . query ( { internal : false } ) ;
630+ const o2Flags = o2 . props . groups . flagsValue ;
631+ const props = o2 . props . groups . props ;
632+ type names = keyof typeof props ;
633+ expectTypeOf < names > ( ) . toEqualTypeOf < "value" > ( ) ;
634+ expectTypeOf < typeof o2Flags > ( ) . toEqualTypeOf < {
635+ nullable : true ;
636+ } > ( ) ;
637+ expect ( o2Flags . nullable ) . toBe ( true ) ;
638+ expect ( Object . keys ( props ) ) . toEqual ( [ "value" ] ) ;
639+ } ) ;
640+ } ) ;
641+
590642describe ( "object.fit" , ( ) => {
591643 const o = s . object ( {
592644 id : s . string ( ) . flags ( { pk : true , internal : true } ) ,
0 commit comments