Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonalling/jest-function
Delightful function testing
https://github.com/simonalling/jest-function
Last synced: about 2 months ago
JSON representation
Delightful function testing
- Host: GitHub
- URL: https://github.com/simonalling/jest-function
- Owner: SimonAlling
- License: mit
- Created: 2019-07-28T12:11:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T04:24:53.000Z (almost 2 years ago)
- Last Synced: 2024-12-04T11:41:03.494Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 681 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jest-function
Delightful function testing.
[![NPM Version][shield-npm]][npm-url]
[![Downloads Stats][shield-downloads]][npm-url]## Installation
```
npm install --save-dev jest-function
```## Usage
```typescript
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
```typescript
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.
[npm-url]: https://npmjs.org/package/jest-function
[shield-npm]: https://img.shields.io/npm/v/jest-function.svg
[shield-downloads]: https://img.shields.io/npm/dm/jest-function.svg