mercredi 4 novembre 2020

vue-test-utils how to test component state

If I have a the following Component state.

data () {
  return {
    tasks: [
              { title: "Task 1", complete: false },
              { title: "Task 2", complete: true }
           ]
  }
}

How would I check that tasks[1].complete === true using Jest?

Here is my current test. I want to check that when trigger("click") event occurs on a checkbox, that the state is changed.

it("Marks a task complete when I click the task checkbox", async () => {
    const wrapper = mount(ToDoList)
    const taskInput = wrapper.find("[data-unit='taskInput']")
    await taskInput.setValue("Buy Milk")
    await taskInput.trigger("keyup.enter")
    await wrapper.find("[data-unit='task-checkbox-0']").trigger("click")
  })

Aucun commentaire:

Enregistrer un commentaire