Skip to content

Commit c60ac8b

Browse files
Bump fast-check from 3.15.0 to 4.0.1 (#2638)
* Bump fast-check from 3.15.0 to 4.0.1 Bumps [fast-check](https://github.com/dubzzz/fast-check/tree/HEAD/packages/fast-check) from 3.15.0 to 4.0.1. - [Release notes](https://github.com/dubzzz/fast-check/releases) - [Changelog](https://github.com/dubzzz/fast-check/blob/main/packages/fast-check/CHANGELOG.md) - [Commits](https://github.com/dubzzz/fast-check/commits/v4.0.1/packages/fast-check) --- updated-dependencies: - dependency-name: fast-check dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Upgrade to latest API --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nicolas Ayral Seydoux <nseydoux@inrupt.com>
1 parent dfa7a3f commit c60ac8b

File tree

3 files changed

+71
-22
lines changed

3 files changed

+71
-22
lines changed

package-lock.json

Lines changed: 36 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
"@types/uuid": "^10.0.0",
187187
"eslint": "^8.56.0",
188188
"eslint-config-next": "^15.0.1",
189-
"fast-check": "^3.15.0",
189+
"fast-check": "^4.0.1",
190190
"jest": "^29.7.0",
191191
"jest-environment-jsdom": "^29.7.0",
192192
"prettier": "3.5.3",

src/rdf.test.ts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe("fromRdfJsDataset", () => {
9191
fcArbitraryLiteral,
9292
);
9393
const fcBlankNode = fc
94-
.asciiString()
94+
.string()
9595
.map((asciiString) => DF.blankNode(asciiString));
9696
const fcDefaultGraph = fc.constant(DF.defaultGraph());
9797
const fcGraph = fc.oneof(fcDefaultGraph, fcNamedNode);
@@ -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

Comments
 (0)