Last active
February 20, 2019 11:40
-
-
Save rickhanlonii/ee1e73da7e1db0e3dbc1bbf812bb093f to your computer and use it in GitHub Desktop.
Mock Test with jest.fn
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
import * as app from "./app"; | |
import * as math from "./math"; | |
math.add = jest.fn(); | |
math.subtract = jest.fn(); | |
test("calls math.add", () => { | |
app.doAdd(1, 2); | |
expect(math.add).toHaveBeenCalledWith(1, 2); | |
}); | |
test("calls math.subtract", () => { | |
app.doSubtract(1, 2); | |
expect(math.subtract).toHaveBeenCalledWith(1, 2); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment