diff --git a/frontend/test/unit/components/containers/ProjectCreationButton.spec.js b/frontend/test/unit/components/containers/ProjectCreationButton.spec.js deleted file mode 100644 index 753cf88f..00000000 --- a/frontend/test/unit/components/containers/ProjectCreationButton.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils' -import Vue from 'vue' -import Vuex from 'vuex' -import Vuetify from 'vuetify' -import ProjectCreationButton from '@/components/containers/ProjectCreationButton' -const localVue = createLocalVue() -localVue.use(Vuex) -Vue.use(Vuetify) - -describe('ProjectCreationButtonContainer', () => { - let store - let projects - let actions - let mutations - - beforeEach(() => { - actions = { - createProject: jest.fn() - } - mutations = {} - projects = { - namespaced: true, - actions, - mutations, - state: {} - } - - store = new Vuex.Store({ - modules: { - projects - } - }) - }) - - test('called createProject action', () => { - const wrapper = shallowMount(ProjectCreationButton, { store, localVue }) - wrapper.vm.createProject() - expect(actions.createProject).toHaveBeenCalled() - }) -}) diff --git a/frontend/test/unit/components/containers/ProjectDeletionButton.spec.js b/frontend/test/unit/components/containers/ProjectDeletionButton.spec.js deleted file mode 100644 index c36bc115..00000000 --- a/frontend/test/unit/components/containers/ProjectDeletionButton.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils' -import Vue from 'vue' -import Vuex from 'vuex' -import Vuetify from 'vuetify' -import ProjectDeletionButton from '@/components/containers/ProjectDeletionButton' -const localVue = createLocalVue() -localVue.use(Vuex) -Vue.use(Vuetify) - -describe('ProjectDeletionButtonContainer', () => { - let store - let projects - let actions - let mutations - - beforeEach(() => { - actions = { - deleteProject: jest.fn() - } - mutations = {} - projects = { - namespaced: true, - actions, - mutations, - state: {} - } - - store = new Vuex.Store({ - modules: { - projects - } - }) - }) - - test('called deleteProject action', () => { - const wrapper = shallowMount(ProjectDeletionButton, { store, localVue }) - wrapper.vm.handleDeleteProject() - expect(actions.deleteProject).toHaveBeenCalled() - }) -}) diff --git a/frontend/test/unit/components/containers/ProjectList.spec.js b/frontend/test/unit/components/containers/ProjectList.spec.js deleted file mode 100644 index f39f29a6..00000000 --- a/frontend/test/unit/components/containers/ProjectList.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils' -import Vuex from 'vuex' -import ProjectList from '@/components/containers/ProjectList' - -const localVue = createLocalVue() -localVue.use(Vuex) - -describe('ProjectListContainer', () => { - let store - let projects - let actions - let mutations - - beforeEach(() => { - actions = { - getProjectList: jest.fn() - } - mutations = { - updateSelected: jest.fn() - } - projects = { - namespaced: true, - actions, - mutations, - state: {} - } - - store = new Vuex.Store({ - modules: { - projects - } - }) - }) - - test('called updateSelected method', () => { - const wrapper = shallowMount(ProjectList, { store, localVue }) - wrapper.vm.update() - expect(mutations.updateSelected).toHaveBeenCalled() - }) -}) diff --git a/frontend/test/unit/components/molecules/.gitkeep b/frontend/test/unit/components/molecules/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/frontend/test/unit/components/organisms/ProjecCreationForm.spec.js b/frontend/test/unit/components/organisms/ProjecCreationForm.spec.js deleted file mode 100644 index c4b638fd..00000000 --- a/frontend/test/unit/components/organisms/ProjecCreationForm.spec.js +++ /dev/null @@ -1,58 +0,0 @@ -import { shallowMount } from '@vue/test-utils' -import Vue from 'vue' -import Vuetify from 'vuetify' -import ProjectCreationForm from '@/components/organisms/ProjectCreationForm' - -Vue.use(Vuetify) - -describe('ProjectCreationForm', () => { - const factory = (propsData) => { - return shallowMount(ProjectCreationForm, { - propsData: { - ...propsData - } - }) - } - const createProject = () => { } - const projectTypes = [] - - test('can receive props', () => { - const wrapper = factory({ createProject, projectTypes }) - expect(wrapper.props()).toEqual({ createProject, projectTypes }) - }) - - test('emit close event', () => { - const wrapper = factory({ createProject, projectTypes }) - wrapper.vm.cancel() - expect(wrapper.emitted('close')).toBeTruthy() - }) - - test('emit close event when form is valid', () => { - const wrapper = factory({ createProject, projectTypes }) - wrapper.setMethods({ - validate: jest.fn(() => true), - reset: jest.fn() - }) - wrapper.vm.create() - expect(wrapper.emitted('close')).toBeTruthy() - }) - - test('do not emit close event when form is invalid', () => { - const wrapper = factory({ createProject, projectTypes }) - wrapper.setMethods({ - validate: jest.fn(() => false), - reset: jest.fn() - }) - wrapper.vm.create() - expect(wrapper.emitted('close')).toBeFalsy() - }) - - test('raise warning when passing no props', () => { - const spy = jest.spyOn(console, 'error') - spy.mockImplementation() - 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 deleted file mode 100644 index 5948b485..00000000 --- a/frontend/test/unit/components/organisms/ProjectList.spec.js +++ /dev/null @@ -1,64 +0,0 @@ -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 = [] - const loading = false - - test('can receive props', () => { - 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, loading } - 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() - expect(spy).toBeCalledWith( - expect.stringContaining('[Vue warn]: Missing required prop') - ) - spy.mockRestore() - }) -}) diff --git a/frontend/test/unit/plugins/filters.spec.js b/frontend/test/unit/plugins/filters.spec.js deleted file mode 100644 index 33ea123e..00000000 --- a/frontend/test/unit/plugins/filters.spec.js +++ /dev/null @@ -1,18 +0,0 @@ -import { truncate } from '@/plugins/filters.js' - -describe('Truncate', () => { - test('dont do nothing', () => { - const string = 'aiueo' - expect(truncate(string)).toEqual(string) - }) - - test('cut the string and add clamp if string length is larger than specified length', () => { - const string = 'aiueo' - expect(truncate(string, 3)).toEqual('aiu...') - }) - - test('dont cut anything if string length is smaller than specified length', () => { - const string = 'aiueo' - expect(truncate(string, 10)).toEqual(string) - }) -}) diff --git a/frontend/test/unit/services/api.service.spec.js b/frontend/test/unit/services/api.service.spec.js deleted file mode 100644 index 6ef893b9..00000000 --- a/frontend/test/unit/services/api.service.spec.js +++ /dev/null @@ -1,56 +0,0 @@ -import MockAdapter from 'axios-mock-adapter' -import ApiService from '@/services/api.service' - -describe('Request', () => { - const r = new ApiService('') - const mockAxios = new MockAdapter(r.instance) - - test('can get resources', async() => { - const data = [ - { - id: 1, - title: 'title', - body: 'body' - } - ] - mockAxios.onGet('/posts').reply(200, data) - const response = await r.get('/posts') - expect(response).toEqual(data) - }) - - test('can create a resource', async() => { - const data = { - title: 'foo', - body: 'bar' - } - mockAxios.onPost('/posts').reply(201, data) - const response = await r.post('/posts', data) - expect(response.title).toEqual(data.title) - }) - - test('can update a resource', async() => { - const data = { - id: 1, - title: 'foo', - body: 'bar' - } - mockAxios.onPut('/posts/1').reply(204, data) - const response = await r.put('/posts/1', data) - expect(response.title).toEqual(data.title) - }) - - test('can partially update a resource', async() => { - const data = { - title: 'foo' - } - mockAxios.onPatch('/posts/1').reply(200, data) - const response = await r.patch('/posts/1', data) - expect(response.title).toEqual(data.title) - }) - - test('can delete a resource', async() => { - mockAxios.onDelete('/posts/1').reply(204, {}) - const response = await r.delete('/posts/1') - expect(response).toEqual({}) - }) -}) diff --git a/frontend/test/unit/services/csv.service.spec.js b/frontend/test/unit/services/csv.service.spec.js deleted file mode 100644 index 3e0d23da..00000000 --- a/frontend/test/unit/services/csv.service.spec.js +++ /dev/null @@ -1,12 +0,0 @@ -import CSVParser from '@/services/parsers/csv.service' - -describe('Request', () => { - const parser = new CSVParser() - - test('can parse text', () => { - const text = 'col 1,col 2\n1,2' - const parsed = parser.parse(text) - expect(parsed.meta.fields).toEqual(['col 1', 'col 2']) - expect(parsed.data[0]['col 1']).toEqual('1') - }) -}) diff --git a/frontend/test/unit/services/project.service.spec.js b/frontend/test/unit/services/project.service.spec.js deleted file mode 100644 index 7bc517b8..00000000 --- a/frontend/test/unit/services/project.service.spec.js +++ /dev/null @@ -1,46 +0,0 @@ -import MockAdapter from 'axios-mock-adapter' -import ProjectService from '@/services/project.service.js' - -describe('Project.service', () => { - const mockAxios = new MockAdapter(ProjectService.request.instance) - - test('can get project list', async() => { - const data = [ - { - 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' - } - ] - mockAxios.onGet('/projects').reply(200, data) - const response = await ProjectService.getProjectList() - expect(response).toEqual(data) - }) - - test('can create a project', async() => { - const data = { - name: 'test project', - description: 'test description', - guideline: 'Please write annotation guideline.', - project_type: 'SequenceLabeling', - randomize_document_order: false - } - mockAxios.onPost('/projects').reply(201, data) - const response = await ProjectService.createProject(data) - expect(response.title).toEqual(data.title) - }) - - test('can delete a project', async() => { - const projectId = 1 - mockAxios.onDelete(`/projects/${projectId}`).reply(204, {}) - const response = await ProjectService.deleteProject(projectId) - expect(response).toEqual({}) - }) -})