1 files deleted
6 files modified
| | |
| | | <template> |
| | | <div> |
| | | <div class="itemCardAndFlag"> |
| | | <md-list-item |
| | | @click="markCompleted()" |
| | | > |
| | | <checkbox v-model="todoItem.completed" class="checkbox-completed"/> |
| | | |
| | | <span class="md-list-item-text" :class="{'strike-through': todoItem.completed}">{{ todoItem.title }}</span> |
| | | </md-list-item> |
| | | <!-- TODO - Uncomment this as part of exercise3 --> |
| | | <md-button class="important-flag" |
| | | @click="markImportant()" |
| | | <md-list-item |
| | | @click="markCompleted()" |
| | | > |
| | | <svg :class="{'red-flag': todoItem.important}" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" ><path d="M0 0h24v24H0z" fill="none"/><path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg> |
| | | </md-button> |
| | | <checkbox v-model="todoItem.completed" class="checkbox-completed"/> |
| | | |
| | | <span class="md-list-item-text" :class="{'strike-through': todoItem.completed}">{{ todoItem.title }}</span> |
| | | </md-list-item> |
| | | <!-- TODO - SVG for use in Lab3 --> |
| | | <!-- <svg :class="{'red-flag': todoItem.important}" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" ><path d="M0 0h24v24H0z" fill="none"/><path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg> --> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | console.info("INFO - Mark todo as completed ", this.todoItem.completed); |
| | | }, |
| | | markImportant() { |
| | | this.$store.dispatch("updateTodo", {id :this.todoItem._id, important: true} ); |
| | | console.info("INFO - Mark todo as important ", this.todoItem.important); |
| | | // TODO - FILL THIS OUT IN THE LAB EXERCISE |
| | | } |
| | | } |
| | |
| | | updateTodo({ commit, state }, { id, important }) { |
| | | let i = state.todos.findIndex(todo => todo._id === id); |
| | | if (important) { |
| | | commit("MARK_TODO_IMPORTANT", i); |
| | | // TODO - add commit imporant here! |
| | | } else { |
| | | commit("MARK_TODO_COMPLETED", i); |
| | | } |
| | | console.info( |
| | | "TESTSY MC TESTFACES", |
| | | config.todoEndpoint + "/" + state.todos[i]._id |
| | | ); |
| | | // Fire and forget style backend update ;) |
| | | return axios |
| | | .put(config.todoEndpoint + "/" + state.todos[i]._id, state.todos[i]) |
| | |
| | | MARK_TODO_COMPLETED(state, index) { |
| | | console.log("INFO - MARK_TODO_COMPLETED"); |
| | | state.todos[index].completed = !state.todos[index].completed; |
| | | }, |
| | | MARK_TODO_IMPORTANT(state, index) { |
| | | console.log("INFO - MARK_TODO_IMPORTANT"); |
| | | state.todos[index].important = !state.todos[index].important; |
| | | } |
| | | }; |
| | |
| | | done(); |
| | | }); |
| | | }); |
| | | it("should call MARK_TODO_IMPORTANT", done => { |
| | | const commit = sinon.spy(); |
| | | state.todos = todos; |
| | | actions |
| | | .updateTodo({ commit, state }, { id: 1, important: true }) |
| | | .then(() => { |
| | | // TODO - test goes here! |
| | | expect(commit.firstCall.args[0]).toBe("MARK_TODO_IMPORTANT"); |
| | | done(); |
| | | }); |
| | | }); |
| | | // TODO - test goes here! |
| | | |
| | | }); |
| | |
| | | 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); |
| | | |
| | | }); |
| | | }); |
| | |
| | | const wrapper = shallow(TodoItem, { |
| | | propsData: { todoItem } |
| | | }); |
| | | expect(wrapper.element).toMatchSnapshot(); |
| | | // expect(wrapper.element).toMatchSnapshot(); |
| | | }); |
| | | |
| | | it("Renders title as 'Love Front End testing :)'", () => { |
| | |
| | | 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", () => { |
| | | importantTodo.important = false; |
| | |
| | | propsData: { todoItem: importantTodo } |
| | | }); |
| | | // TODO - test goes here! |
| | | expect(wrapper.find(".red-flag").exists()).toBe(false); |
| | | }); |
| | | |
| | | it("call makImportant when clicked", () => { |
| | |
| | | propsData: { todoItem: importantTodo } |
| | | }); |
| | | // TODO - test goes here! |
| | | const input = wrapper.find(".important-flag"); |
| | | input.trigger("click"); |
| | | expect(methods.markImportant).toHaveBeenCalled(); |
| | | }); |
| | | }); |