-
-
Save dvallin/613e2a13d03e310e2c636f767b65e308 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("actions", () => { | |
const mockContext = (foundTask: Task) => { | |
return { | |
getters: { taskByTitle:(s) => foundTask }, | |
commit: jest.fn() | |
}; | |
}; | |
it("adds tasks if they cannot be found", () => { | |
const context = mockContext(undefined); | |
const taskTitle = "title"; | |
actions.addTask(context, { | |
type: Actions.AddTask, | |
title: taskTitle | |
}); | |
expect(context.commit).toHaveBeenCalledWith({ | |
type: Mutations.TaskAdded, | |
task: new Task(taskTitle) | |
}); | |
}); | |
it("does not add tasks if they can be found", () => { | |
const taskTitle = "title"; | |
const context = mockContext(new Task(taskTitle)); | |
actions.addTask(context, { | |
type: Actions.AddTask, | |
title: taskTitle | |
}); | |
expect(context.commit).toHaveBeenCalledTimes(0); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment