diff --git a/mithril-explorer/Makefile b/mithril-explorer/Makefile index 1aea11ac33..725fdb1139 100644 --- a/mithril-explorer/Makefile +++ b/mithril-explorer/Makefile @@ -65,12 +65,10 @@ upgrade: clean install react-chartjs-2@latest \ react-dom@latest \ react-redux@latest \ - @fast-check/jest@latest \ @testing-library/jest-dom@latest \ @testing-library/react@latest \ eslint@latest \ eslint-config-next@latest \ - @fast-check/jest@latest \ fantasticon@latest \ jest@latest \ jest-environment-jsdom@latest \ diff --git a/mithril-explorer/__tests__/DownloadImmutableFormInput.test.js b/mithril-explorer/__tests__/DownloadImmutableFormInput.test.js index b3da7a335c..1fc5d66952 100644 --- a/mithril-explorer/__tests__/DownloadImmutableFormInput.test.js +++ b/mithril-explorer/__tests__/DownloadImmutableFormInput.test.js @@ -1,16 +1,13 @@ import { fireEvent, render, screen } from "@testing-library/react"; -import { test, fc } from "@fast-check/jest"; import "@testing-library/jest-dom"; import { DownloadImmutableFormInput } from "#/Artifacts/CardanoDbV2SnapshotsList/DownloadButton"; -const maxImmutable = 100000; +const maxImmutable = 100_000; function setup(max) { const utils = render(); return { - // Note: in `fast-check` tests `screen.getByRole("spinbutton")` find two elements for a reason I don't understand, so - // I'm using getAllByRole and selecting the first one to avoid the error. - input: screen.getAllByRole("spinbutton")[0], + input: screen.getByRole("spinbutton"), ...utils, }; } @@ -29,35 +26,32 @@ describe("DownloadImmutableFormInput", () => { expect(input.value).toBe(""); }); - test.prop({ - immutable_file_number: fc.nat({ - max: maxImmutable, - }), - })("Immutable below or equal to max allowed", ({ immutable_file_number }) => { - const { input } = setup(maxImmutable); - fireEvent.change(input, { - // target: { value: `${immutable_file_number}` }, - target: { value: immutable_file_number }, - }); + it.each([0, 123, 67_782, maxImmutable])( + "Immutable below or equal to max allowed: %d", + (immutable_file_number) => { + const { input } = setup(maxImmutable); + fireEvent.change(input, { + target: { value: immutable_file_number }, + }); - expect(input.checkValidity()).toBeTruthy(); - expect(input.value).toBe(`${immutable_file_number}`); - }); + expect(input.checkValidity()).toBeTruthy(); + expect(input.value).toBe(`${immutable_file_number}`); + }, + ); - test.prop({ - immutable_file_number: fc.oneof(fc.integer({ max: -1 }), fc.integer({ min: maxImmutable + 1 })), - })("Immutable above max or below 0 is invalid", ({ immutable_file_number }) => { - const { input } = setup(maxImmutable); - fireEvent.change(input, { - target: { value: immutable_file_number }, - }); + it.each([-4328, -1, maxImmutable + 1, 528_432])( + "Immutable above max or below 0 is invalid: %d", + (immutable_file_number) => { + const { input } = setup(maxImmutable); + fireEvent.change(input, { + target: { value: immutable_file_number }, + }); - expect(input.checkValidity()).toBeFalsy(); - }); + expect(input.checkValidity()).toBeFalsy(); + }, + ); - test.prop({ - immutable_file_number: fc.string({ minLength: 1 }).filter((s) => isNaN(parseInt(s))), - })("Non-number is invalid", ({ immutable_file_number }) => { + it.each(["@124", "⚠️", "text"])("Non-number is invalid: %s", (immutable_file_number) => { const { input } = setup({ maxImmutable }); fireEvent.change(input, { target: { value: immutable_file_number }, @@ -66,9 +60,7 @@ describe("DownloadImmutableFormInput", () => { expect(input.checkValidity()).toBeFalsy(); }); - test.prop({ - immutable_file_number: fc.float({ noInteger: true }), - })("Float is invalid", ({ immutable_file_number }) => { + it.each([0.1, 1.432, 67_782.32])("Float is invalid: %f", ({ immutable_file_number }) => { const { input } = setup({ maxImmutable }); fireEvent.change(input, { target: { value: immutable_file_number }, diff --git a/mithril-explorer/package-lock.json b/mithril-explorer/package-lock.json index 424ad6b7a1..b75627603d 100644 --- a/mithril-explorer/package-lock.json +++ b/mithril-explorer/package-lock.json @@ -22,13 +22,11 @@ "react-redux": "^9.2.0" }, "devDependencies": { - "@fast-check/jest": "^2.0.3", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.2.0", "eslint": "^9.18.0", "eslint-config-next": "^15.1.5", "fantasticon": "^3.0.0", - "fast-check": "^3.23.2", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "next-router-mock": "^0.9.13", @@ -669,38 +667,6 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "node_modules/@fast-check/jest": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@fast-check/jest/-/jest-2.0.3.tgz", - "integrity": "sha512-3bRtz5kmM2GyLSm9qkDEepeulPaMWZMjjXhOl1G6TCuIghDCPN75pKi2FjXVhkRjTZc6TlMjrcX4f0rTGwM2bQ==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/dubzzz" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fast-check" - } - ], - "dependencies": { - "fast-check": "^3.0.0" - }, - "peerDependencies": { - "@fast-check/worker": ">=0.0.7 <0.5.0", - "@jest/expect": ">=28.0.0", - "@jest/globals": ">=25.5.2" - }, - "peerDependenciesMeta": { - "@fast-check/worker": { - "optional": true - }, - "@jest/expect": { - "optional": true - } - } - }, "node_modules/@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -4691,28 +4657,6 @@ "node": ">= 16.0.0" } }, - "node_modules/fast-check": { - "version": "3.23.2", - "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-3.23.2.tgz", - "integrity": "sha512-h5+1OzzfCC3Ef7VbtKdcv7zsstUQwUDlYpUTvjeUsJAssPgLn7QzbboPtL5ro04Mq0rPOsMzl7q5hIbRs2wD1A==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/dubzzz" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fast-check" - } - ], - "dependencies": { - "pure-rand": "^6.1.0" - }, - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", diff --git a/mithril-explorer/package.json b/mithril-explorer/package.json index 07c5d21929..fdff032f9f 100644 --- a/mithril-explorer/package.json +++ b/mithril-explorer/package.json @@ -27,13 +27,11 @@ "react-redux": "^9.2.0" }, "devDependencies": { - "@fast-check/jest": "^2.0.3", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.2.0", "eslint": "^9.18.0", "eslint-config-next": "^15.1.5", "fantasticon": "^3.0.0", - "fast-check": "^3.23.2", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "next-router-mock": "^0.9.13",