Skip to content

Commit

Permalink
Add no regression tests for commands (#355)
Browse files Browse the repository at this point in the history
* Add no regression tests for commands

* No regression tests not display absolute paths
  • Loading branch information
dubzzz committed May 12, 2019
1 parent 3a77cbc commit 8713ee8
Show file tree
Hide file tree
Showing 5 changed files with 464 additions and 62 deletions.
35 changes: 35 additions & 0 deletions test/e2e/NoRegression.spec.ts
@@ -1,4 +1,11 @@
import fc from '../../src/fast-check';
import {
IncreaseCommand,
DecreaseCommand,
EvenCommand,
OddCommand,
CheckLessThanCommand
} from './model/CounterCommands';

const testFunc = (value: unknown) => {
const repr = fc.stringify(value);
Expand Down Expand Up @@ -213,4 +220,32 @@ describe(`NoRegression`, () => {
it('emailAddress', () => {
expect(() => fc.assert(fc.property(fc.emailAddress(), v => testFunc(v)), settings)).toThrowErrorMatchingSnapshot();
});
it('commands', () => {
expect(() =>
fc.assert(
fc.property(
fc.commands([
fc.nat().map(n => new IncreaseCommand(n)),
fc.nat().map(n => new DecreaseCommand(n)),
fc.constant(new EvenCommand()),
fc.constant(new OddCommand()),
fc.nat().map(n => new CheckLessThanCommand(n + 1))
]),
cmds => {
const setup = () => ({
model: { count: 0 },
real: {}
});
try {
fc.modelRun(setup, cmds);
return true;
} catch (err) {
return false;
}
}
),
settings
)
).toThrowErrorMatchingSnapshot();
});
});

0 comments on commit 8713ee8

Please sign in to comment.