Skip to content

Instantly share code, notes, and snippets.

@kantord
Created June 11, 2018 19:01
Show Gist options
  • Save kantord/bbe39c18c96ab1b13cafa98b094a4e45 to your computer and use it in GitHub Desktop.
Save kantord/bbe39c18c96ab1b13cafa98b094a4e45 to your computer and use it in GitHub Desktop.
milestone3.js
// @flow
type Environment = {
+left: ?number,
+right: ?number,
}
type AssertionValues = {
+result: ?number,
}
describe(
'Min',
Suite.Function(
(_: Specimen) => ({
[_(it)]: (environment: Environment) => require('./Min'),
...({left, right}: Environment, {result}: AssertionValues) => ({
result: Min => expect(Min(left, right)).toEqual(result),
error: Min => expect(() => Min(left, right)).toThrow(),
}),
}),
(_: Experiment) =>
_.with(
{
left: 4,
},
_ => _.and({right: 6}).produces({result: 4}),
_ => _.and({right: 3}).produces({result: 3}),
_ => _.and({right: 'asd'}).produces('error'),
),
(_: Experiment) =>
_.taking('left').from([null, undefined, 'foo'], _ =>
_.and('right')
.sample(3) // .sample takes the first 3 numbers from iterable
.example() // example takes one random element from the sample every time
.from(Suite.Integers)
.produces('error'),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment