-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create breakage tests for the testing modules
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
1 parent
73961bf
commit 58c45f9
Showing
2 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}, | ||
); |