tests/unit/javascript/actions.spec.js | ●●●●● patch | view | raw | blame | history | |
tests/unit/javascript/mutations.spec.js | ●●●●● patch | view | raw | blame | history | |
tests/unit/vue-components/TodoItem.spec.js | ●●●●● patch | view | raw | blame | history |
tests/unit/javascript/actions.spec.js
@@ -129,7 +129,7 @@ actions .updateTodo({ commit, state }, { id: 1, important: true }) .then(() => { // console.log(commit.firstCall.args[0]) // TODO - test goes here! expect(commit.firstCall.args[0]).toBe("MARK_TODO_IMPORTANT"); done(); }); tests/unit/javascript/mutations.spec.js
@@ -3,22 +3,27 @@ let state; const todo = { completed: true, title: "testing sucks" completed: true, title: "testing sucks" }; const newTodo = "biscuits"; const doneTodos = [{ const doneTodos = [ { completed: true, title: "testing sucks" },{ }, { completed: false, title: "easy testing is fun" }]; const importantTodos = [{ } ]; const importantTodos = [ { completed: true, title: "testing sucks", important: true }] } ]; describe("Mutation tests", () => { beforeEach(() => { @@ -44,7 +49,7 @@ }); it("ADD_TODO", () => { state.todos = [] state.todos = []; mutations.ADD_TODO(state, todo); expect(state.todos.length).toBe(1); }); @@ -52,13 +57,13 @@ it("CLEAR_NEW_TODO", () => { state.newTodo = newTodo; mutations.CLEAR_NEW_TODO(state, newTodo); expect(state.newTodo).toEqual(''); expect(state.newTodo).toEqual(""); }); it("CLEAR_NEW_TODO", () => { state.newTodo = newTodo; mutations.CLEAR_NEW_TODO(state); expect(state.newTodo).toEqual(''); expect(state.newTodo).toEqual(""); }); it("CLEAR_ALL_DONE_TODOS", () => { @@ -85,12 +90,14 @@ it("it should MARK_TODO_IMPORTANT as false", () => { state.todos = importantTodos; // TODO - test goes here! mutations.MARK_TODO_IMPORTANT(state, 0); expect(state.todos[0].important).toBe(false); }); it("it should MARK_TODO_IMPORTANT as true", () => { state.todos = importantTodos; // TODO - test goes here! state.todos[0].important = false; mutations.MARK_TODO_IMPORTANT(state, 0); expect(state.todos[0].important).toBe(true); tests/unit/vue-components/TodoItem.spec.js
@@ -35,27 +35,6 @@ }); expect(wrapper.vm.todoItem.completed).toEqual(true); }); // it("won't render additional props", () => { // const biscuits = "digestives" // const wrapper = shallow(TodoItem, { // propsData: { biscuits } // }); // expect(wrapper.vm.todoItem).toBe("undefined"); // }); // it("renders props.placeholderMsg when passed", () => { // const msg = "Add a Todo"; // const wrapper = shallow(NewTodo, { // propsData: { placeholderMsg: msg } // }); // expect(wrapper.vm._props.placeholderMsg).toMatch(msg); // }); // it("renders newTodo as empty string", () => { // const wrapper = shallow(NewTodo, {}); // expect(wrapper.vm.newTodo).toMatch(""); // }); }); let importantTodo; @@ -75,12 +54,14 @@ const wrapper = mount(TodoItem, { propsData: { todoItem: importantTodo } }); // TODO - test goes here! expect(wrapper.find(".important-flag").exists()).toBe(true); }); it("should set the colour to red when true", () => { const wrapper = mount(TodoItem, { propsData: { todoItem: importantTodo } }); // TODO - test goes here! expect(wrapper.find(".red-flag").exists()).toBe(true); }); it("should set the colour to not red when false", () => { @@ -88,6 +69,7 @@ const wrapper = mount(TodoItem, { propsData: { todoItem: importantTodo } }); // TODO - test goes here! expect(wrapper.find(".red-flag").exists()).toBe(false); }); @@ -96,6 +78,7 @@ methods, propsData: { todoItem: importantTodo } }); // TODO - test goes here! const input = wrapper.find(".important-flag"); input.trigger("click"); expect(methods.markImportant).toHaveBeenCalled();