Browse Source

Add unit test for organisms/ProjectList

pull/341/head
Hironsan 5 years ago
parent
commit
344b7ab0a3
2 changed files with 64 additions and 0 deletions
  1. 0
      frontend/test/unit/components/organisms/.gitkeep
  2. 64
      frontend/test/unit/components/organisms/ProjectList.spec.js

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

64
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()
})
})
Loading…
Cancel
Save