Skip to content

Instantly share code, notes, and snippets.

@dvallin
Created November 29, 2017 16:46
Show Gist options
  • Save dvallin/5761d5efe2d6fb15b90ca2dc6e97a0f2 to your computer and use it in GitHub Desktop.
Save dvallin/5761d5efe2d6fb15b90ca2dc6e97a0f2 to your computer and use it in GitHub Desktop.
beforeEach(() => {
TasksApi.addTask = jest.fn();
});
it("adds tasks if they cannot be found", async () => {
const context = mockContext(undefined);
const taskTitle = "title";
const task = new Task(taskTitle);
TasksApi.addTask.mockReturnValueOnce(
Promise.resolve(task)
);
await actions.addTask(context, {
type: Actions.AddTask,
title: taskTitle
});
expect(context.commit).toHaveBeenCalledWith({
type: Mutations.AddTaskSucceeded,
task
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment