Skip to content

Commit

Permalink
Merge branch 'main' into expand-testing-module
Browse files Browse the repository at this point in the history
  • Loading branch information
ericcornelissen committed Oct 11, 2023
2 parents bb51695 + 3e99c28 commit 0578b38
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion stryker.integration.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
32 changes: 24 additions & 8 deletions test/integration/testing/commonjs.test.js
Original file line number Diff line number Diff line change
@@ -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()],
Expand Down Expand Up @@ -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);
},
);
19 changes: 17 additions & 2 deletions test/integration/testing/functional.test.js
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down
14 changes: 0 additions & 14 deletions test/unit/testing/injection-strings.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/unit/testing/stubscape.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 1 addition & 5 deletions testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 0578b38

Please sign in to comment.