AzureCredentialsForm.test.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import AzureCredentialsForm, { Props } from './AzureCredentialsForm';
  4. const setup = (propOverrides?: object) => {
  5. const props: Props = {
  6. selectedAzureCloud: 'azuremonitor',
  7. selectedSubscription: '44693801-6ee6-49de-9b2d-9106972f9572',
  8. azureCloudOptions: [
  9. { value: 'azuremonitor', label: 'Azure' },
  10. { value: 'govazuremonitor', label: 'Azure US Government' },
  11. { value: 'germanyazuremonitor', label: 'Azure Germany' },
  12. { value: 'chinaazuremonitor', label: 'Azure China' },
  13. ],
  14. tenantId: 'e7f3f661-a933-4b3f-8176-51c4f982ec48',
  15. clientId: '77409fad-c0a9-45df-9e25-f1ff95af6554',
  16. clientSecret: '',
  17. clientSecretConfigured: false,
  18. subscriptionOptions: [],
  19. onAzureCloudChange: jest.fn(),
  20. onSubscriptionSelectChange: jest.fn(),
  21. onTenantIdChange: jest.fn(),
  22. onClientIdChange: jest.fn(),
  23. onClientSecretChange: jest.fn(),
  24. onResetClientSecret: jest.fn(),
  25. onLoadSubscriptions: jest.fn(),
  26. };
  27. Object.assign(props, propOverrides);
  28. return shallow(<AzureCredentialsForm {...props} />);
  29. };
  30. describe('Render', () => {
  31. it('should render component', () => {
  32. const wrapper = setup();
  33. expect(wrapper).toMatchSnapshot();
  34. });
  35. it('should disable azure monitor secret input', () => {
  36. const wrapper = setup({
  37. clientSecretConfigured: true,
  38. });
  39. expect(wrapper).toMatchSnapshot();
  40. });
  41. it('should enable azure monitor load subscriptions button', () => {
  42. const wrapper = setup({
  43. clientSecret: 'e7f3f661-a933-4b3f-8176-51c4f982ec48',
  44. });
  45. expect(wrapper).toMatchSnapshot();
  46. });
  47. });