Skip to content

Instantly share code, notes, and snippets.

@goldblade
Created March 25, 2019 00:05
Show Gist options
  • Select an option

  • Save goldblade/b304269fa086491854602a0ff3e4784b to your computer and use it in GitHub Desktop.

Select an option

Save goldblade/b304269fa086491854602a0ff3e4784b to your computer and use it in GitHub Desktop.
atena-testes.js
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