Skip to content

Instantly share code, notes, and snippets.

@rickhanlonii
Last active March 4, 2018 19:29
Show Gist options
  • Save rickhanlonii/b6ac9092cd35b11bf811a5fb8ff21f99 to your computer and use it in GitHub Desktop.
Save rickhanlonii/b6ac9092cd35b11bf811a5fb8ff21f99 to your computer and use it in GitHub Desktop.
Mock Dependency Injection
const doAdd = (a, b, callback) => {
callback(a + b);
};
test("calls callback with arguments added", () => {
const mockCallback = jest.fn();
doAdd(1, 2, mockCallback);
expect(mockCallback).toHaveBeenCalledWith(3);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment