mirror of https://github.com/doccano/doccano.git
Hironsan
5 years ago
6 changed files with 4 additions and 163 deletions
Split View
Diff Options
-
0frontend/test/integration/organisms/.gitkeep
-
46frontend/test/integration/organisms/ProjectDeletionForm.spec.js
-
0frontend/test/unit/components/molecules/.gitkeep
-
55frontend/test/unit/components/molecules/Modal.spec.js
-
59frontend/test/unit/components/organisms/ProjectDeletionForm.spec.js
-
7frontend/test/unit/components/organisms/ProjectList.spec.js
@ -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() |
|||
}) |
|||
}) |
@ -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: '<div data-test="slotContent">slot content</div>' |
|||
} |
|||
}) |
|||
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) |
|||
}) |
|||
}) |
@ -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() |
|||
}) |
|||
}) |
Write
Preview
Loading…
Cancel
Save