installWizard.spec.jsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import React from 'react';
  2. import {mount} from 'sentry-test/enzyme';
  3. import ConfigStore from 'app/stores/configStore';
  4. import InstallWizard from 'app/views/installWizard';
  5. jest.mock('app/stores/configStore', () => ({
  6. get: jest.fn(),
  7. }));
  8. describe('InstallWizard', function() {
  9. beforeAll(function() {
  10. ConfigStore.get.mockImplementation(key => {
  11. if (key === 'version') {
  12. return {
  13. current: '1.33.7',
  14. };
  15. }
  16. return {};
  17. });
  18. MockApiClient.addMockResponse({
  19. url: '/internal/options/?query=is:required',
  20. body: TestStubs.InstallWizard(),
  21. });
  22. });
  23. beforeEach(function() {});
  24. it('renders', function() {
  25. const wrapper = mount(<InstallWizard onConfigured={jest.fn()} />);
  26. expect(wrapper).toMatchSnapshot();
  27. });
  28. it('has no option selected when beacon.anonymous is unset', function() {
  29. MockApiClient.addMockResponse({
  30. url: '/internal/options/?query=is:required',
  31. body: TestStubs.InstallWizard({
  32. 'beacon.anonymous': {
  33. field: {
  34. disabledReason: null,
  35. default: false,
  36. required: true,
  37. disabled: false,
  38. allowEmpty: true,
  39. isSet: false,
  40. },
  41. value: false,
  42. },
  43. }),
  44. });
  45. const wrapper = mount(<InstallWizard onConfigured={jest.fn()} />);
  46. expect(
  47. wrapper.find('input[name="beacon.anonymous"][value="false"]').prop('checked')
  48. ).toBe(false);
  49. expect(
  50. wrapper.find('input[name="beacon.anonymous"][value="true"]').prop('checked')
  51. ).toBe(false);
  52. });
  53. it('has no option selected even when beacon.anonymous is set', function() {
  54. MockApiClient.addMockResponse({
  55. url: '/internal/options/?query=is:required',
  56. body: TestStubs.InstallWizard({
  57. 'beacon.anonymous': {
  58. field: {
  59. disabledReason: null,
  60. default: false,
  61. required: true,
  62. disabled: false,
  63. allowEmpty: true,
  64. isSet: true,
  65. },
  66. value: false,
  67. },
  68. }),
  69. });
  70. const wrapper = mount(<InstallWizard onConfigured={jest.fn()} />);
  71. expect(
  72. wrapper.find('input[name="beacon.anonymous"][value="false"]').prop('checked')
  73. ).toBe(false);
  74. expect(
  75. wrapper.find('input[name="beacon.anonymous"][value="true"]').prop('checked')
  76. ).toBe(false);
  77. });
  78. });