You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.6 KiB

  1. import { shallowMount } from '@vue/test-utils'
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify'
  4. import ProjectList from '@/components/organisms/ProjectList'
  5. Vue.use(Vuetify)
  6. describe('ProjectList', () => {
  7. const projects = [
  8. {
  9. id: 1,
  10. name: 'CoNLL 2003',
  11. description: 'This is a project for NER.',
  12. guideline: 'Please write annotation guideline.',
  13. users: [
  14. 1
  15. ],
  16. project_type: 'SequenceLabeling',
  17. image: '/static/assets/images/cats/sequence_labeling.jpg',
  18. updated_at: '2019-07-09T06:19:29.789091Z',
  19. randomize_document_order: false,
  20. resourcetype: 'SequenceLabelingProject'
  21. }
  22. ]
  23. const headers = [
  24. {
  25. text: 'Name',
  26. align: 'left',
  27. value: 'name'
  28. },
  29. {
  30. text: 'Description',
  31. value: 'description'
  32. },
  33. {
  34. text: 'Type',
  35. value: 'project_type'
  36. }
  37. ]
  38. const selected = []
  39. const loading = false
  40. test('can receive props', () => {
  41. const propsData = { projects, headers, selected, loading }
  42. const wrapper = shallowMount(ProjectList, { propsData })
  43. expect(wrapper.props()).toEqual(propsData)
  44. })
  45. test('emitted update event', () => {
  46. const propsData = { projects, headers, selected, loading }
  47. const wrapper = shallowMount(ProjectList, { propsData })
  48. wrapper.vm.update(propsData)
  49. expect(wrapper.emitted('update')).toBeTruthy()
  50. })
  51. test('raise warning when passing props', () => {
  52. const spy = jest.spyOn(console, 'error')
  53. spy.mockImplementation()
  54. expect(spy).toBeCalledWith(
  55. expect.stringContaining('[Vue warn]: Missing required prop')
  56. )
  57. spy.mockRestore()
  58. })
  59. })