Created
July 5, 2018 06:18
-
-
Save ceilfors/aee161e807dff6ccc5e436693680a3ff to your computer and use it in GitHub Desktop.
better-dependency-injection-with-laconia
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 { handler } = require("./lambda"); | |
let twitterService; | |
beforeEach(() => { | |
// Creates a mocked twitterService | |
twitterService = { | |
getLatestTweets: jest.fn().mockReturnValue(Promise.resolve()) | |
}; | |
}); | |
it("should get tweets for user 1000", () => { | |
// Runs your exported handler function with the mocked dependencies | |
handler.run({ twitterService }); | |
expect(twitterService.getLatestTweets).toBeCalledWith(1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment