diff --git a/frontend/test/integration/organisms/.gitkeep b/frontend/test/integration/organisms/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/frontend/test/integration/organisms/ProjectDeletionForm.spec.js b/frontend/test/integration/organisms/ProjectDeletionForm.spec.js deleted file mode 100644 index 53c56479..00000000 --- a/frontend/test/integration/organisms/ProjectDeletionForm.spec.js +++ /dev/null @@ -1,46 +0,0 @@ -import { mount } from '@vue/test-utils' -import Vue from 'vue' -import Vuetify from 'vuetify' -import ProjectDeletionForm from '@/components/organisms/ProjectDeletionForm' - -Vue.use(Vuetify) - -describe('ProjectDeletionForm', () => { - const selected = [ - { - 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 factory = (propsData) => { - return mount(ProjectDeletionForm, { - propsData: { - ...propsData - } - }) - } - - test('emit close event when cancel button is clicked', () => { - const wrapper = factory({ selected }) - const button = wrapper.find('[data-test="cancel-button"]') - button.trigger('click') - expect(wrapper.emitted('close')).toBeTruthy() - }) - - test('emit delete event when delete button is clicked', () => { - const wrapper = factory({ selected }) - const button = wrapper.find('[data-test="delete-button"]') - button.trigger('click') - expect(wrapper.emitted('delete')).toBeTruthy() - }) -}) diff --git a/frontend/test/unit/components/molecules/.gitkeep b/frontend/test/unit/components/molecules/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/frontend/test/unit/components/molecules/Modal.spec.js b/frontend/test/unit/components/molecules/Modal.spec.js deleted file mode 100644 index 3741eb50..00000000 --- a/frontend/test/unit/components/molecules/Modal.spec.js +++ /dev/null @@ -1,55 +0,0 @@ -import { shallowMount } from '@vue/test-utils' -import Vue from 'vue' -import Vuetify from 'vuetify' -import Modal from '@/components/Modal.vue' - -Vue.use(Vuetify) - -describe('Modal', () => { - test('can receive props', () => { - const propsData = { - title: 'test title', - button: 'test text' - } - const wrapper = shallowMount(Modal, { propsData }) - expect(wrapper.props()).toEqual(propsData) - }) - - test('can insert content into slot', () => { - const wrapper = shallowMount(Modal, { - slots: { - default: '
slot content
' - } - }) - const slotContent = wrapper.find('[data-test="slotContent"]') - expect(slotContent.exists()).toBe(true) - expect(slotContent.text()).toBe('slot content') - }) - - test('is closed by default', () => { - const wrapper = shallowMount(Modal) - expect(wrapper.vm.dialog).toBe(false) - }) - - test('can open dialog', () => { - const wrapper = shallowMount(Modal) - wrapper.vm.open() - expect(wrapper.vm.dialog).toBe(true) - }) - - test('can close after agree', () => { - const wrapper = shallowMount(Modal) - wrapper.vm.open() - expect(wrapper.vm.dialog).toBe(true) - wrapper.vm.agree() - expect(wrapper.vm.dialog).toBe(false) - }) - - test('can close after cancel', () => { - const wrapper = shallowMount(Modal) - wrapper.vm.open() - expect(wrapper.vm.dialog).toBe(true) - wrapper.vm.cancel() - expect(wrapper.vm.dialog).toBe(false) - }) -}) diff --git a/frontend/test/unit/components/organisms/ProjectDeletionForm.spec.js b/frontend/test/unit/components/organisms/ProjectDeletionForm.spec.js deleted file mode 100644 index 2d48767e..00000000 --- a/frontend/test/unit/components/organisms/ProjectDeletionForm.spec.js +++ /dev/null @@ -1,59 +0,0 @@ -import { shallowMount } from '@vue/test-utils' -import Vue from 'vue' -import Vuetify from 'vuetify' -import ProjectDeletionForm from '@/components/organisms/ProjectDeletionForm' - -Vue.use(Vuetify) - -describe('ProjectDeletionForm', () => { - const selected = [ - { - 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 factory = (propsData) => { - return shallowMount(ProjectDeletionForm, { - propsData: { - ...propsData - } - }) - } - - test('can receive props', () => { - const wrapper = factory({ selected }) - expect(wrapper.props()).toEqual({ selected }) - }) - - test('emit close event', () => { - const wrapper = factory({ selected }) - wrapper.vm.cancel(selected) - expect(wrapper.emitted('close')).toBeTruthy() - }) - - test('emit delete event', () => { - const wrapper = factory({ selected }) - wrapper.vm.deleteProject(selected) - expect(wrapper.emitted('delete')).toBeTruthy() - }) - - test('raise warning when passing no props', () => { - const spy = jest.spyOn(console, 'error') - spy.mockImplementation() - const wrapper = factory() - expect(spy).toBeCalledWith( - expect.stringContaining('[Vue warn]: Missing required prop') - ) - spy.mockRestore() - }) -}) diff --git a/frontend/test/unit/components/organisms/ProjectList.spec.js b/frontend/test/unit/components/organisms/ProjectList.spec.js index 8198a887..92b6e204 100644 --- a/frontend/test/unit/components/organisms/ProjectList.spec.js +++ b/frontend/test/unit/components/organisms/ProjectList.spec.js @@ -20,7 +20,7 @@ describe('ProjectList', () => { updated_at: '2019-07-09T06:19:29.789091Z', randomize_document_order: false, resourcetype: 'SequenceLabelingProject' - }, + } ] const headers = [ { @@ -38,15 +38,16 @@ describe('ProjectList', () => { } ] const selected = [] + const loading = false test('can receive props', () => { - const propsData = { projects, headers, selected } + const propsData = { projects, headers, selected, loading } const wrapper = shallowMount(ProjectList, { propsData }) expect(wrapper.props()).toEqual(propsData) }) test('emitted update event', () => { - const propsData = { projects, headers, selected } + const propsData = { projects, headers, selected, loading } const wrapper = shallowMount(ProjectList, { propsData }) wrapper.vm.update(propsData) expect(wrapper.emitted('update')).toBeTruthy()