Created
March 25, 2019 00:05
-
-
Save goldblade/b304269fa086491854602a0ff3e4784b to your computer and use it in GitHub Desktop.
atena-testes.js
This file contains hidden or 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
| describe("save", () => { | |
| describe("rocket origin", () => { | |
| afterEach(() => jest.restoreAllMocks()); | |
| it("should returns reject promise when user not in rocket database", async () => { | |
| const data = message; | |
| data.origin = "rocket"; | |
| await expect(interaction.save(message)).rejects.toEqual( | |
| "add new interaction" | |
| ); | |
| }); | |
| it("should returns successfully when user is on rocket database", async () => { | |
| const data = message; | |
| data.origin = "rocket"; | |
| jest | |
| .spyOn(interactionModel.prototype, "save") | |
| .mockImplementationOnce(() => Promise.resolve(saveInteraction)); | |
| interaction.validInteraction = jest | |
| .fn() | |
| .mockReturnValue(new Promise(resolve => resolve(true))); | |
| const response = await interaction.save(message); | |
| expect(response).toEqual(saveInteraction); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment