@@ -855,76 +855,7 @@ describe('formatter', () => {
855855 } ) ;
856856
857857 describe ( 'convert' , ( ) => {
858- it ( 'should convert array values correctly when schema is an array and items are objects' , ( ) => {
859- const schema = {
860- type : 'object' ,
861- properties : {
862- transactions : {
863- type : 'array' ,
864- oneOf : [
865- {
866- items : {
867- type : 'object' ,
868- properties : {
869- address : { format : 'string' } ,
870- value : { type : 'string' } ,
871- } ,
872- } ,
873- } ,
874- {
875- items : {
876- type : 'object' ,
877- properties : {
878- address : { format : 'string' } ,
879- value : { type : 'number' } ,
880- } ,
881- } ,
882- } ,
883- ] ,
884- } ,
885- } ,
886- } ;
887- const data = {
888- transactions : [
889- { address : 'B' , value : '42' } ,
890- { address : 'B' , value : 43 } ,
891- ] ,
892- } ;
893- expect (
894- convert ( data , schema , [ ] , {
895- number : FMT_NUMBER . HEX ,
896- bytes : FMT_BYTES . HEX ,
897- } ) ,
898- ) . toEqual ( data ) ;
899- } ) ;
900-
901- it ( 'should delete the array property if schema for array items is nullish' , ( ) => {
902- const schema = {
903- type : 'object' ,
904- properties : {
905- transactions : {
906- type : 'array' ,
907- items : undefined , // Simulate a missing or null schema for items
908- } ,
909- } ,
910- } ;
911-
912- const data = {
913- transactions : [
914- { type : 'A' , value : 'some string' } ,
915- { type : 'B' , value : 42 } ,
916- ] ,
917- } ;
918-
919- const result = convert ( data , schema , [ ] , {
920- number : FMT_NUMBER . HEX ,
921- bytes : FMT_BYTES . HEX ,
922- } ) ;
923-
924- expect ( result ) . toEqual ( { } ) ;
925- } ) ;
926-
927- it ( 'should return empty when no proerties or items' , ( ) => {
858+ it ( 'should return empty when no properties or items' , ( ) => {
928859 const data = { key : 'value' } ;
929860 const schema = {
930861 type : 'object' ,
@@ -933,44 +864,5 @@ describe('formatter', () => {
933864 const result = convert ( data , schema , [ ] , f , [ ] ) ;
934865 expect ( result ) . toEqual ( { } ) ;
935866 } ) ;
936-
937- it ( 'should format nested objects with oneOf' , ( ) => {
938- const schema = {
939- type : 'object' ,
940- properties : {
941- details : {
942- type : 'object' ,
943- oneOf : [
944- { properties : { type : { enum : [ 'A' ] } , value : { type : 'string' } } } ,
945- { properties : { type : { enum : [ 'B' ] } , value : { type : 'number' } } } ,
946- ] ,
947- } ,
948- } ,
949- } ;
950-
951- const data = {
952- details : {
953- type : 'B' ,
954- value : 42 ,
955- } ,
956- } ;
957- const result = convert (
958- data ,
959- schema ,
960- [ ] ,
961- {
962- number : FMT_NUMBER . BIGINT ,
963- bytes : FMT_BYTES . UINT8ARRAY ,
964- } ,
965- [ [ 'details' , 1 ] ] ,
966- ) ;
967-
968- expect ( result ) . toEqual ( {
969- details : {
970- type : 'B' ,
971- value : 42 ,
972- } ,
973- } ) ;
974- } ) ;
975867 } ) ;
976868} ) ;
0 commit comments