Skip to content

Commit

Permalink
fc.commands provides an Iterable<>
Browse files Browse the repository at this point in the history
It will allow future changes to change the output from array to anything else if necessary
  • Loading branch information
dubzzz committed Aug 23, 2018
1 parent 7e78ee7 commit 2b63e3d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/model-based-testing/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AddTrackCommand implements MusicPlayerCommand {

describe('MusicPlayer', () => {
const TrackNameArb = fc.hexaString(1, 10);
const CommandsArb: fc.Arbitrary<MusicPlayerCommand[]> = fc.commands([
const CommandsArb = fc.commands([
fc.constant(new PlayCommand()),
fc.constant(new PauseCommand()),
fc.constant(new NextCommand()),
Expand Down
2 changes: 1 addition & 1 deletion src/check/model/commands/CommandsArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CommandWrapper } from './CommandWrapper';
export const commands = <Model extends object, Real, RunResult>(
commandArbs: Arbitrary<ICommand<Model, Real, RunResult>>[],
maxCommands?: number
): Arbitrary<ICommand<Model, Real, RunResult>[]> => {
): Arbitrary<Iterable<ICommand<Model, Real, RunResult>>> => {
const internalCommandArb: Arbitrary<CommandWrapper<Model, Real, RunResult>> = oneof(...commandArbs).map(
c => new CommandWrapper(c)
);
Expand Down
6 changes: 3 additions & 3 deletions test/unit/check/model/commands/CommandsArbitrary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class FailureCommand implements Cmd {

describe('CommandWrapper', () => {
describe('commands', () => {
const simulateCommands = (cmds: Cmd[]) => {
const simulateCommands = (cmds: Iterable<Cmd>) => {
for (const c of cmds) {
if (!c.check(model)) continue;
try {
Expand All @@ -72,7 +72,7 @@ describe('CommandWrapper', () => {

for (const shrunkCmds of baseCommands.shrink()) {
logOnCheck.data = [];
shrunkCmds.value.forEach(c => c.check(model));
[...shrunkCmds.value].forEach(c => c.check(model));
assert.ok(logOnCheck.data.every(e => e !== 'skipped'));
}
})
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('CommandWrapper', () => {

for (const shrunkCmds of baseCommands.shrink()) {
logOnCheck.data = [];
shrunkCmds.value.forEach(c => c.check(model));
[...shrunkCmds.value].forEach(c => c.check(model));
assert.ok(logOnCheck.data.every(e => e === 'failure' || e === 'success'));
assert.ok(logOnCheck.data.filter(e => e === 'failure').length <= 1);
}
Expand Down

0 comments on commit 2b63e3d

Please sign in to comment.