@@ -600,9 +600,20 @@ describe("toRdfJsDataset", () => {
600600 fc . uniqueArray ( fc . string ( ) , { minLength : 1 } ) ,
601601 )
602602 . filter ( isNotEmpty ) ;
603+ // Replaced deprecated hexaString with custom implementation for v4
604+ const hexaChars = "0123456789abcdef" ;
605+ const hexa = ( ) => {
606+ return fc . integer ( { min : 0 , max : 15 } ) . map (
607+ ( n ) => hexaChars [ n ] ,
608+ ( c ) => hexaChars . indexOf ( < string > c ) ,
609+ ) ;
610+ } ;
611+ const hexaString = ( constraints : fc . StringConstraints = { } ) =>
612+ fc . string ( { ...constraints , unit : hexa ( ) } ) ;
613+
603614 const fcLangStrings = fc
604615 . dictionary (
605- fc . hexaString ( { minLength : 1 } ) . map ( ( str ) => str . toLowerCase ( ) ) ,
616+ hexaString ( { minLength : 1 } ) . map ( ( str ) => str . toLowerCase ( ) ) ,
606617 fc . uniqueArray ( fc . string ( ) , { minLength : 1 } ) ,
607618 )
608619 . filter ( isNotEmpty ) ;
@@ -619,16 +630,28 @@ describe("toRdfJsDataset", () => {
619630 minLength : 1 ,
620631 } ,
621632 ) ;
633+ // withDeletedKeys option was removed in v4, achieve similar functionality with filter
622634 const fcObjects = fc
623- . record (
624- {
625- literals : fcLiterals ,
626- langStrings : fcLangStrings ,
627- namedNodes : fcNamedNodes ,
628- // blankNodes: fcBlankNodes,
629- } ,
630- { withDeletedKeys : true } ,
631- )
635+ . record ( {
636+ literals : fcLiterals ,
637+ langStrings : fcLangStrings ,
638+ namedNodes : fcNamedNodes ,
639+ // blankNodes: fcBlankNodes,
640+ } )
641+ . map ( ( obj ) => {
642+ // Randomly delete some keys to achieve similar behavior to withDeletedKeys
643+ const keys = Object . keys ( obj ) as Array < keyof typeof obj > ;
644+ if ( keys . length <= 1 ) return obj ; // Keep at least one property
645+
646+ const result = { ...obj } ;
647+ // Delete random keys with 50% chance for each
648+ keys . forEach ( ( key ) => {
649+ if ( Math . random ( ) < 0.5 && Object . keys ( result ) . length > 1 ) {
650+ delete result [ key ] ;
651+ }
652+ } ) ;
653+ return result ;
654+ } )
632655 . filter ( isNotEmpty ) ;
633656 // Unfortunately I haven't figured out how to generate the nested blank node
634657 // structures with fast-check yet, so this does not generate those:
0 commit comments