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.

59 lines
1.6 KiB

  1. import { shallowMount } from '@vue/test-utils'
  2. import Vue from 'vue'
  3. import Vuetify from 'vuetify'
  4. import ProjectDeletionForm from '@/components/organisms/ProjectDeletionForm'
  5. Vue.use(Vuetify)
  6. describe('ProjectDeletionForm', () => {
  7. const selected = [
  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 factory = (propsData) => {
  24. return shallowMount(ProjectDeletionForm, {
  25. propsData: {
  26. ...propsData
  27. }
  28. })
  29. }
  30. test('can receive props', () => {
  31. const wrapper = factory({ selected })
  32. expect(wrapper.props()).toEqual({ selected })
  33. })
  34. test('emit close event', () => {
  35. const wrapper = factory({ selected })
  36. wrapper.vm.cancel(selected)
  37. expect(wrapper.emitted('close')).toBeTruthy()
  38. })
  39. test('emit delete event', () => {
  40. const wrapper = factory({ selected })
  41. wrapper.vm.deleteProject(selected)
  42. expect(wrapper.emitted('delete')).toBeTruthy()
  43. })
  44. test('raise warning when passing no props', () => {
  45. const spy = jest.spyOn(console, 'error')
  46. spy.mockImplementation()
  47. const wrapper = factory()
  48. expect(spy).toBeCalledWith(
  49. expect.stringContaining('[Vue warn]: Missing required prop')
  50. )
  51. spy.mockRestore()
  52. })
  53. })