test.jsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import React from 'react'
  15. import { shallow } from 'enzyme'
  16. import WizardSummary from '.'
  17. const wrap = props => shallow(<WizardSummary {...props} />)
  18. let data = {
  19. options: {
  20. description: 'A description',
  21. field_name: 'Field name value',
  22. },
  23. selectedInstances: [
  24. { flavor_name: 'flavor_name', id: 'i-1', name: 'name', num_cpu: 2, memory_mb: 1024 },
  25. ],
  26. networks: [
  27. {
  28. sourceNic: { id: 's-1', network_name: 'n-1' },
  29. targetNetwork: { name: 'target network' },
  30. },
  31. ],
  32. source: {
  33. type: 'openstack',
  34. name: 'source name',
  35. },
  36. target: {
  37. type: 'azure',
  38. name: 'target name',
  39. },
  40. schedules: [
  41. {
  42. id: 's-1',
  43. schedule: {
  44. month: 2,
  45. dom: 14,
  46. dow: 3,
  47. minute: 0,
  48. hour: 17,
  49. },
  50. },
  51. ],
  52. }
  53. describe('WizardSummary Component', () => {
  54. it('renders overview section', () => {
  55. let wrapper = wrap({ data, wizardType: 'replica' })
  56. expect(wrapper.html().indexOf('source name') > -1).toBe(true)
  57. expect(wrapper.find('StatusPill').at(0).prop('label')).toBe('OPENSTACK')
  58. expect(wrapper.html().indexOf('target name') > -1).toBe(true)
  59. expect(wrapper.find('StatusPill').at(1).prop('label')).toBe('AZURE')
  60. expect(wrapper.find('StatusPill').at(2).prop('label')).toBe('REPLICA')
  61. })
  62. it('renders instances section', () => {
  63. let wrapper = wrap({ data, wizardType: 'replica' })
  64. expect(wrapper.html().indexOf('flavor_name') > -1).toBe(true)
  65. })
  66. it('renders networks section', () => {
  67. let wrapper = wrap({ data, wizardType: 'replica' })
  68. expect(wrapper.html().indexOf('target network') > -1).toBe(true)
  69. expect(wrapper.html().indexOf('n-1') > -1).toBe(true)
  70. })
  71. it('renders options section', () => {
  72. let wrapper = wrap({ data, wizardType: 'replica' })
  73. expect(wrapper.html().indexOf('Description') > -1).toBe(true)
  74. expect(wrapper.html().indexOf('A description') > -1).toBe(true)
  75. expect(wrapper.html().indexOf('Field Name') > -1).toBe(true)
  76. expect(wrapper.html().indexOf('Field name value') > -1).toBe(true)
  77. })
  78. it('renders schedule section', () => {
  79. let wrapper = wrap({ data, wizardType: 'replica' })
  80. let scheduleText = wrapper.findWhere(w => w.prop('data-test-id') === `scheduleItem-${data.schedules[0].id}`).dive().text()
  81. expect(scheduleText).toBe('Every February, every 14th, every Wednesday, at 17:00')
  82. })
  83. })