Skip to content

Commit

Permalink
Create breakage tests for the testing modules
Browse files Browse the repository at this point in the history
Expand the breakage test suite with a test file for the shescape/testing
module. This suite is a bit interesting because it contains some skipped
tests. These tests are skipped because of bugfixes and an API extension
which both occurred in [1].

The breakage coverage configuration is also updated to include the
testing module in the coverage report.

--
1. 4f03fd8
  • Loading branch information
ericcornelissen committed Oct 21, 2023
1 parent 73961bf commit 58c45f9
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .c8/breakage.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"all": true,
"include": ["src/", "index.js"],
"include": ["src/", "index.js", "testing.js"],
"exclude": [],
"check-coverage": false,
"reports-dir": "_reports/coverage/breakage",
Expand Down
151 changes: 151 additions & 0 deletions test/breakage/testing.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/**
* @overview Contains breakage tests for the shescape testing module.
* @license MIT
*/

import { testProp } from "@fast-check/ava";
import * as fc from "fast-check";

import { arbitrary } from "./_.js";

import { Shescape as Stubscape, Throwscape } from "shescape/testing";
import { Shescape as Previoustub } from "shescape-previous/testing";

testProp(
"Stubscape#escape",
[arbitrary.shescapeOptions(), fc.anything()],
(t, options, arg) => {
let result, previousResult, errored, previousErrored;
let stubscape, previoustub;

try {
stubscape = new Stubscape(options);
result = stubscape.escape(arg);
} catch (_) {
errored = true;
}

try {
previoustub = new Previoustub(options);
previousResult = previoustub.escape(arg);
} catch (_) {
previousErrored = true;
}

t.is(errored, previousErrored);
t.is(typeof result, typeof previousResult);
},
);

testProp(
"Stubscape#escapeAll",
[
arbitrary.shescapeOptions(),
fc.oneof(fc.anything(), fc.array(fc.anything())),
],
(t, options, args) => {
let result, previousResult, errored, previousErrored;
let stubscape, previoustub;

try {
stubscape = new Stubscape(options);
result = stubscape.escapeAll(args);
} catch (_) {
errored = true;
}

try {
previoustub = new Previoustub(options);
previousResult = previoustub.escapeAll(args);
} catch (_) {
previousErrored = true;
}

t.is(errored, previousErrored);
t.is(typeof result, typeof previousResult);
},
);

// TODO: unskip upon release 2.0.1/2.1.0. It's currently skipped because the
// implementation was incorrect in 2.0.0 and has been fixed since (in 4f03fd8).
testProp.skip(
"Stubscape#quote",
[arbitrary.shescapeOptions(), fc.anything()],
(t, options, arg) => {
let result, previousResult, errored, previousErrored;
let stubscape, previoustub;

try {
stubscape = new Stubscape(options);
result = stubscape.quote(arg);
} catch (_) {
errored = true;
}

try {
previoustub = new Previoustub(options);
previousResult = previoustub.quote(arg);
} catch (_) {
previousErrored = true;
}

t.is(errored, previousErrored);
t.is(typeof result, typeof previousResult);
},
);

// TODO: unskip upon release 2.0.1/2.1.0. It's currently skipped because the
// implementation was incorrect in 2.0.0 and has been fixed since (in 4f03fd8).
testProp.skip(
"Stubscape#quoteAll",
[
arbitrary.shescapeOptions(),
fc.oneof(fc.anything(), fc.array(fc.anything())),
],
(t, options, args) => {
let result, previousResult, errored, previousErrored;
let stubscape, previoustub;

try {
stubscape = new Stubscape(options);
result = stubscape.quoteAll(args);
} catch (_) {
errored = true;
}

try {
previoustub = new Previoustub(options);
previousResult = previoustub.quoteAll(args);
} catch (_) {
previousErrored = true;
}

t.is(errored, previousErrored);
t.is(typeof result, typeof previousResult);
},
);

// TODO: unskip upon release 2.0.1/2.1.0. It's currently skipped because the
// `Throwscape` class was not yet release in 2.0.0 (added in 4f03fd8).
testProp.skip(
"Throwscape#constructor",
[arbitrary.shescapeOptions()],
(t, options) => {
let errored, previousErrored;
let throwscape, previousthrow;

try {
throwscape = new Throwscape(options);
} catch (_) {
errored = true;
}

try {
previousthrow = new Previousthrow(options);
} catch (_) {
previousErrored = true;
}

t.is(errored, previousErrored);
},
);

0 comments on commit 58c45f9

Please sign in to comment.