Skip to content

feat: create the package #1

@janhesters

Description

@janhesters

Create the code so that you can mock a function like this:

import mockFunction from 'mock-function';

const add = (a: number, b: number) => a + b;
const mockedAdd = mockFunction(add);

mockedAdd.hasBeenCalled();
// ↵ false

mockedAdd(42, 42);
// ↵ 42
mockedAdd(9000, 1);
// ↵ 9001 (😱 OVER 9000)

mockedAdd.hasBeenCalled();
// ↵ true

mockedAdd.hasBeenCalledWith(2000, 12);
// ↵ false
mockedAdd.hasBeenCalledWith(42, 42);
// ↵ true

mockedAdd.calls
// ↵ [[42, 42], [9000, 1]]

Metadata

Metadata

Assignees

Labels

featA new feature

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions