diff --git a/frontend/test/unit/components/organisms/.gitkeep b/frontend/test/unit/components/organisms/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/frontend/test/unit/components/organisms/ProjectList.spec.js b/frontend/test/unit/components/organisms/ProjectList.spec.js new file mode 100644 index 00000000..8198a887 --- /dev/null +++ b/frontend/test/unit/components/organisms/ProjectList.spec.js @@ -0,0 +1,64 @@ +import { shallowMount } from '@vue/test-utils' +import Vue from 'vue' +import Vuetify from 'vuetify' +import ProjectList from '@/components/organisms/ProjectList' + +Vue.use(Vuetify) + +describe('ProjectList', () => { + const projects = [ + { + id: 1, + name: 'CoNLL 2003', + description: 'This is a project for NER.', + guideline: 'Please write annotation guideline.', + users: [ + 1 + ], + project_type: 'SequenceLabeling', + image: '/static/assets/images/cats/sequence_labeling.jpg', + updated_at: '2019-07-09T06:19:29.789091Z', + randomize_document_order: false, + resourcetype: 'SequenceLabelingProject' + }, + ] + const headers = [ + { + text: 'Name', + align: 'left', + value: 'name' + }, + { + text: 'Description', + value: 'description' + }, + { + text: 'Type', + value: 'project_type' + } + ] + const selected = [] + + test('can receive props', () => { + const propsData = { projects, headers, selected } + const wrapper = shallowMount(ProjectList, { propsData }) + expect(wrapper.props()).toEqual(propsData) + }) + + test('emitted update event', () => { + const propsData = { projects, headers, selected } + const wrapper = shallowMount(ProjectList, { propsData }) + wrapper.vm.update(propsData) + expect(wrapper.emitted('update')).toBeTruthy() + }) + + test('raise warning when passing props', () => { + const spy = jest.spyOn(console, 'error') + spy.mockImplementation() + const wrapper = shallowMount(ProjectList) + expect(spy).toBeCalledWith( + expect.stringContaining('[Vue warn]: Missing required prop') + ) + spy.mockRestore() + }) +})