Skip to content

Instantly share code, notes, and snippets.

@dvallin
Created November 29, 2017 16:46
Show Gist options
  • Save dvallin/ad674e4a22aba65604f001858347c1e4 to your computer and use it in GitHub Desktop.
Save dvallin/ad674e4a22aba65604f001858347c1e4 to your computer and use it in GitHub Desktop.
import TodoList from '@/components/TodoList'
import TodoListItem from '@/components/TodoListItem'
import {Task} from "@/domain/Task";
import {shallow} from 'vue-test-utils'
const task = new Task("Some Title");
describe('TodoList.vue', () => {
it('renders empty lists', () => {
const cmp = shallow(TodoList, {
propsData: {
tasks: []
}
});
expect(cmp.element).toMatchSnapshot();
expect(cmp.vm.$el.childNodes.length).toBe(0);
});
it('renders three element lists', () => {
const cmp = shallow(TodoList, {
propsData: {
tasks: [task,task,task]
}
});
expect(cmp.element).toMatchSnapshot();
expect(cmp.find(TodoListItem).vm.task.title).toEqual('Some Title');
expect(cmp.findAll(TodoListItem).length).toBe(3);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment