Browse Source

Delete unnecessary tests

pull/341/head
Hironsan 5 years ago
parent
commit
d4f9e81d73
6 changed files with 4 additions and 163 deletions
  1. 0
      frontend/test/integration/organisms/.gitkeep
  2. 46
      frontend/test/integration/organisms/ProjectDeletionForm.spec.js
  3. 0
      frontend/test/unit/components/molecules/.gitkeep
  4. 55
      frontend/test/unit/components/molecules/Modal.spec.js
  5. 59
      frontend/test/unit/components/organisms/ProjectDeletionForm.spec.js
  6. 7
      frontend/test/unit/components/organisms/ProjectList.spec.js

0
frontend/test/integration/organisms/.gitkeep

46
frontend/test/integration/organisms/ProjectDeletionForm.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()
})
})

0
frontend/test/unit/components/molecules/.gitkeep

55
frontend/test/unit/components/molecules/Modal.spec.js

@ -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)
})
})

59
frontend/test/unit/components/organisms/ProjectDeletionForm.spec.js

@ -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()
})
})

7
frontend/test/unit/components/organisms/ProjectList.spec.js

@ -20,7 +20,7 @@ describe('ProjectList', () => {
updated_at: '2019-07-09T06:19:29.789091Z', updated_at: '2019-07-09T06:19:29.789091Z',
randomize_document_order: false, randomize_document_order: false,
resourcetype: 'SequenceLabelingProject' resourcetype: 'SequenceLabelingProject'
},
}
] ]
const headers = [ const headers = [
{ {
@ -38,15 +38,16 @@ describe('ProjectList', () => {
} }
] ]
const selected = [] const selected = []
const loading = false
test('can receive props', () => { test('can receive props', () => {
const propsData = { projects, headers, selected }
const propsData = { projects, headers, selected, loading }
const wrapper = shallowMount(ProjectList, { propsData }) const wrapper = shallowMount(ProjectList, { propsData })
expect(wrapper.props()).toEqual(propsData) expect(wrapper.props()).toEqual(propsData)
}) })
test('emitted update event', () => { test('emitted update event', () => {
const propsData = { projects, headers, selected }
const propsData = { projects, headers, selected, loading }
const wrapper = shallowMount(ProjectList, { propsData }) const wrapper = shallowMount(ProjectList, { propsData })
wrapper.vm.update(propsData) wrapper.vm.update(propsData)
expect(wrapper.emitted('update')).toBeTruthy() expect(wrapper.emitted('update')).toBeTruthy()

Loading…
Cancel
Save