-
-
Save dvallin/3c26c8852a3d1eb875c9a29023250507 to your computer and use it in GitHub Desktop.
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
beforeEach(() => { | |
axios.get = jest.fn(); | |
axios.post = jest.fn(); | |
}); | |
describe("add task", () => { | |
it("maps added task into reponse", () => { | |
const task = new Task("task"); | |
axios.post.mockReturnValueOnce(Promise.resolve({data: task})); | |
return expect(TasksApi.addTask("task")).resolves.toEqual(task); | |
}); | |
it("hands error down", () => { | |
const error = {}; | |
axios.post.mockReturnValueOnce(Promise.reject(error)); | |
return expect(TasksApi.addTask("task")).rejects.toEqual(error); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment