@@ -622,6 +622,109 @@ describe("traverse", () => {
622
622
} ) ;
623
623
} ) ;
624
624
625
+ it ( "traverses contains" , ( ) => {
626
+ const testSchema : any = {
627
+ contains : { type : "string" }
628
+ } ;
629
+ const mockMutation = jest . fn ( ( mockS ) => mockS ) ;
630
+
631
+ traverse ( testSchema , mockMutation ) ;
632
+
633
+ expect ( mockMutation ) . nthCalledWith (
634
+ 1 ,
635
+ testSchema . contains ,
636
+ expect . anything ( ) ,
637
+ expect . anything ( ) ,
638
+ expect . anything ( ) ,
639
+ ) ;
640
+ expect ( mockMutation ) . nthCalledWith (
641
+ 2 ,
642
+ testSchema ,
643
+ expect . anything ( ) ,
644
+ expect . anything ( ) ,
645
+ undefined ,
646
+ ) ;
647
+
648
+ expect ( mockMutation ) . toHaveBeenCalledTimes ( 2 ) ;
649
+ } ) ;
650
+
651
+ it ( "traverses propertyNames" , ( ) => {
652
+ const testSchema : any = {
653
+ propertyNames : { type : "string" }
654
+ } ;
655
+ const mockMutation = jest . fn ( ( mockS ) => mockS ) ;
656
+
657
+ traverse ( testSchema , mockMutation ) ;
658
+
659
+ expect ( mockMutation ) . nthCalledWith (
660
+ 1 ,
661
+ testSchema . propertyNames ,
662
+ expect . anything ( ) ,
663
+ expect . anything ( ) ,
664
+ expect . anything ( ) ,
665
+ ) ;
666
+ expect ( mockMutation ) . nthCalledWith (
667
+ 2 ,
668
+ testSchema ,
669
+ expect . anything ( ) ,
670
+ expect . anything ( ) ,
671
+ undefined ,
672
+ ) ;
673
+
674
+ expect ( mockMutation ) . toHaveBeenCalledTimes ( 2 ) ;
675
+ } ) ;
676
+
677
+ it ( "traverses unevaluatedItems as boolean" , ( ) => {
678
+ const testSchema : any = {
679
+ unevaluatedItems : false ,
680
+ } ;
681
+ const mockMutation = jest . fn ( ( mockS ) => mockS ) ;
682
+
683
+ traverse ( testSchema , mockMutation ) ;
684
+
685
+ expect ( mockMutation ) . nthCalledWith (
686
+ 1 ,
687
+ testSchema . unevaluatedItems ,
688
+ expect . anything ( ) ,
689
+ expect . anything ( ) ,
690
+ expect . anything ( ) ,
691
+ ) ;
692
+ expect ( mockMutation ) . nthCalledWith (
693
+ 2 ,
694
+ testSchema ,
695
+ expect . anything ( ) ,
696
+ expect . anything ( ) ,
697
+ undefined ,
698
+ ) ;
699
+
700
+ expect ( mockMutation ) . toHaveBeenCalledTimes ( 2 ) ;
701
+ } ) ;
702
+
703
+ it ( "traverses unevaluatedProperties as schema" , ( ) => {
704
+ const testSchema : any = {
705
+ unevaluatedProperties : { type : "string" } ,
706
+ } ;
707
+ const mockMutation = jest . fn ( ( mockS ) => mockS ) ;
708
+
709
+ traverse ( testSchema , mockMutation ) ;
710
+
711
+ expect ( mockMutation ) . nthCalledWith (
712
+ 1 ,
713
+ testSchema . unevaluatedProperties ,
714
+ expect . anything ( ) ,
715
+ expect . anything ( ) ,
716
+ expect . anything ( ) ,
717
+ ) ;
718
+ expect ( mockMutation ) . nthCalledWith (
719
+ 2 ,
720
+ testSchema ,
721
+ expect . anything ( ) ,
722
+ expect . anything ( ) ,
723
+ undefined ,
724
+ ) ;
725
+
726
+ expect ( mockMutation ) . toHaveBeenCalledTimes ( 2 ) ;
727
+ } ) ;
625
728
626
729
describe ( "schema.type being an array" , ( ) => {
627
730
it ( "allows type to be an array" , ( ) => {
@@ -1092,8 +1195,6 @@ describe("traverse", () => {
1092
1195
) ;
1093
1196
} ) ;
1094
1197
} ) ;
1095
- } ) ;
1096
-
1097
1198
describe ( "Mutability settings" , ( ) => {
1098
1199
it ( "defaults to being immutable" , ( ) => {
1099
1200
const s = {
@@ -1266,3 +1367,4 @@ describe("Mutability settings", () => {
1266
1367
} ) ;
1267
1368
} ) ;
1268
1369
} ) ;
1370
+ } ) ;
0 commit comments