Created
June 14, 2022 07:56
-
-
Save davidbarral/27d1f88a9a1f03dd1eb82a341f627afc to your computer and use it in GitHub Desktop.
DI Pragmatic 3
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 mockUpdate = jest.fn(); | |
jest.mock("./repos/user.js", () => () => ({ | |
update: mockUpdate; | |
})); | |
jest.beforeEach(() => jest.restoreAllMocks()); | |
const updateUserPreference = require("./use-cases/update-user-preference.js"); | |
it("updates the user preference", () => { | |
updateUserPreference({ key: "someKey", value: "someValue" }); | |
expect(mockUpdate).toHaveBeenCalledWith(/* the updatedUser */); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment