-
-
Save dvallin/d6ed70e4cec436b6bbd326e6d6997d96 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
describe("fetch tasks", () => { | |
beforeEach(() => { | |
TasksApi.fetchTasks = jest.fn(); | |
}); | |
it("calls success if api succeeds", async () => { | |
const context = mockContext(undefined); | |
const tasks = []; | |
TasksApi.fetchTasks.mockReturnValueOnce( | |
Promise.resolve(tasks) | |
); | |
await actions.fetchTasks(context, { | |
type: Actions.FetchTasks | |
}); | |
expect(context.commit).toHaveBeenCalledWith({ | |
type: Mutations.FetchTasksSucceeded, | |
tasks | |
}); | |
}); | |
it("calls error handling on error", async () => { | |
const context = mockContext(undefined); | |
const error = {info: "Server Out of Potatoes Exception"}; | |
TasksApi.fetchTasks.mockReturnValueOnce( | |
Promise.reject(error) | |
); | |
await actions.fetchTasks(context, { | |
type: Actions.FetchTasks | |
}); | |
expect(context.commit).toHaveBeenCalledWith({ | |
type: Mutations.FetchTasksFailed, | |
error | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment