Last active
March 4, 2018 19:29
-
-
Save rickhanlonii/b6ac9092cd35b11bf811a5fb8ff21f99 to your computer and use it in GitHub Desktop.
Mock Dependency Injection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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