diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a583bf53c..d0a241137 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -161,7 +161,7 @@ jobs: - name: Checkout repository uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - name: Install tooling - uses: asdf-vm/actions/install@6a442392015fbbdd8b48696d41e0051b2698b2e4 # v2.2.0 + uses: asdf-vm/actions/install@4f8f7939dd917fc656bb7c3575969a5988c28364 # v3.0.0 - name: Install Node.js uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 with: diff --git a/stryker.integration.config.js b/stryker.integration.config.js index f7a8e0834..8e4714b47 100644 --- a/stryker.integration.config.js +++ b/stryker.integration.config.js @@ -3,7 +3,7 @@ export default { coverageAnalysis: "perTest", inPlace: false, - mutate: ["index.js"], + mutate: ["index.js", "testing.js"], testRunner: "tap", tap: { testFiles: ["test/integration/**/*.test.js"], diff --git a/test/integration/testing/commonjs.test.js b/test/integration/testing/commonjs.test.js index a0576fd24..49d425f78 100644 --- a/test/integration/testing/commonjs.test.js +++ b/test/integration/testing/commonjs.test.js @@ -1,20 +1,36 @@ /** * @overview Contains integration tests for the CommonJS version of the testing - * implementations of Shescape. + * utilities provided with Shescape. * @license MIT */ import { testProp } from "@fast-check/ava"; +import test from "ava"; import * as fc from "fast-check"; import { arbitrary } from "../_.js"; -import { Shescape as Stubscape, Throwscape } from "shescape/testing"; import { + injectionStrings, + Shescape as Stubscape, + Throwscape, +} from "shescape/testing"; +import { + injectionStrings as injectionStringsCjs, Shescape as StubscapeCjs, Throwscape as ThrowscapeCjs, } from "../../../testing.cjs"; +test("injection strings", (t) => { + for (const injectionStringCjs of injectionStringsCjs) { + t.true(injectionStrings.includes(injectionStringCjs)); + } + + for (const injectionString of injectionStrings) { + t.true(injectionStringsCjs.includes(injectionString)); + } +}); + testProp( "Stubscape#escape (esm === cjs)", [arbitrary.shescapeArg(), arbitrary.shescapeOptions()], @@ -97,20 +113,20 @@ testProp( "Throwscape#constructor (esm === cjs)", [arbitrary.shescapeOptions()], (t, options) => { - let errorEsm, errorCjs; + let erroredEsm, erroredCjs; try { new Throwscape(options); - } catch (error) { - errorEsm = error; + } catch (_) { + erroredEsm = true; } try { new ThrowscapeCjs(options); - } catch (error) { - errorCjs = error; + } catch (_) { + erroredCjs = true; } - t.deepEqual(errorEsm, errorCjs); + t.deepEqual(erroredEsm, erroredCjs); }, ); diff --git a/test/integration/testing/functional.test.js b/test/integration/testing/functional.test.js index ec84f75db..7991a6be7 100644 --- a/test/integration/testing/functional.test.js +++ b/test/integration/testing/functional.test.js @@ -1,16 +1,31 @@ /** - * @overview Contains integration tests for the testing implementations of + * @overview Contains integration tests for the testing utilities provided with * Shescape. * @license MIT */ import { testProp } from "@fast-check/ava"; +import test from "ava"; import * as fc from "fast-check"; import { arbitrary } from "../_.js"; import { Shescape } from "shescape"; -import { Shescape as Stubscape, Throwscape } from "shescape/testing"; +import { + injectionStrings, + Shescape as Stubscape, + Throwscape, +} from "shescape/testing"; + +test("injection strings", (t) => { + t.true(Array.isArray(injectionStrings)); + t.true(injectionStrings.length > 0); + + for (const injectionString of injectionStrings) { + t.is(typeof injectionString, "string"); + t.true(injectionString.length > 0); + } +}); testProp( "Stubscape#escape (stubscape =~ shescape)", diff --git a/test/unit/testing/injection-strings.test.js b/test/unit/testing/injection-strings.test.js deleted file mode 100644 index 85d1b926b..000000000 --- a/test/unit/testing/injection-strings.test.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @overview Contains unit tests for the injection strings test helper. - * @license MIT - */ - -import test from "ava"; - -import { injectionStrings } from "../../../testing.js"; - -test("types", (t) => { - for (const injectionString of injectionStrings) { - t.is(typeof injectionString, "string"); - } -}); diff --git a/test/unit/testing/stubscape.test.js b/test/unit/testing/stubscape.test.js index d5f1bc8cf..348a90a63 100644 --- a/test/unit/testing/stubscape.test.js +++ b/test/unit/testing/stubscape.test.js @@ -146,7 +146,7 @@ test("quoteAll invalid arguments", (t) => { testProp( "quoteAll without a shell", [ - fc.array(arbitrary.shescapeArg()), + fc.array(arbitrary.shescapeArg(), { minLength: 1 }), arbitrary.shescapeOptions().filter((options) => options?.shell === false), ], (t, args, options) => { diff --git a/testing.js b/testing.js index 9e999149a..d0e8ea424 100644 --- a/testing.js +++ b/testing.js @@ -58,11 +58,7 @@ export class Shescape { } quoteAll(args) { - if (this.shell === false) { - throw new Error(); - } - - return this.escapeAll(args); + return args.map((arg) => this.quote(arg)); } }