jest-function
v1.0.1
Published
Delightful function testing.
Downloads
12
Maintainers
Readme
jest-function
Delightful function testing.
Installation
npm install --save-dev jest-function
Usage
import { check } from "jest-function";
function length(s: string): number {
return s.length;
}
it(`length`, () => {
check(length).against([
{ in: "", out: 0 },
{ in: "hello", out: 5 },
]);
// Equivalent:
expect(length("")).toEqual(0);
expect(length("hello")).toEqual(5);
});
n-ary functions
function add(a: number, b: number): number {
return a + b;
}
it(`add`, () => {
const tuplifiedAdd = (args: [number, number]) => add(...args);
check(tuplifiedAdd).against([
{ in: [0, 0], out: 0 },
{ in: [2, 5], out: 7 },
]);
});
Contribute
npm run verify
lints, builds and tests the package.