index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { shallowMount } from '@vue/test-utils'
  2. import OsSelect from '../index'
  3. import { IMAGES_TYPE_MAP } from '@/constants/compute'
  4. import i18n from '@/locales'
  5. let setFieldsValue = null
  6. let decorator = null
  7. const $route = {
  8. query: {
  9. },
  10. }
  11. beforeEach(() => {
  12. setFieldsValue = jest.fn()
  13. decorator = {
  14. os: [
  15. 'os',
  16. {
  17. initialValue: '',
  18. rules: [
  19. { required: true, message: i18n.t('compute.text_153') },
  20. ],
  21. },
  22. ],
  23. image: [
  24. 'image',
  25. {
  26. initialValue: { key: '', label: '' },
  27. },
  28. ],
  29. imageType: [
  30. 'imageType',
  31. {
  32. initialValue: 'standard',
  33. },
  34. ],
  35. }
  36. })
  37. describe('OsSelect', () => {
  38. it('IDC base', () => {
  39. const type = 'idc'
  40. const hypervisor = 'kvm'
  41. const wrapper = shallowMount(OsSelect, {
  42. provide () {
  43. return {
  44. form: {
  45. fc: {
  46. setFieldsValue,
  47. },
  48. },
  49. }
  50. },
  51. propsData: {
  52. decorator,
  53. type,
  54. hypervisor,
  55. },
  56. mocks: {
  57. $route,
  58. },
  59. })
  60. expect(wrapper.vm.mirrorTypeOptions).toEqual([IMAGES_TYPE_MAP.standard, IMAGES_TYPE_MAP.customize, IMAGES_TYPE_MAP.iso, IMAGES_TYPE_MAP.host, IMAGES_TYPE_MAP.snapshot])
  61. expect(wrapper.vm.$el).toMatchSnapshot()
  62. })
  63. })