awsLambdaCloudformation.spec.jsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import * as qs from 'query-string';
  2. import {mountWithTheme} from 'sentry-test/enzyme';
  3. import {selectByValue} from 'sentry-test/select-new';
  4. import AwsLambdaCloudformation from 'sentry/views/integrationPipeline/awsLambdaCloudformation';
  5. describe('AwsLambdaCloudformation', () => {
  6. let wrapper;
  7. let windowAssignMock;
  8. beforeEach(() => {
  9. windowAssignMock = jest.fn();
  10. window.location.assign = windowAssignMock;
  11. window.localStorage.setItem('AWS_EXTERNAL_ID', 'my-id');
  12. wrapper = mountWithTheme(
  13. <AwsLambdaCloudformation
  14. baseCloudformationUrl="https://console.aws.amazon.com/cloudformation/home#/stacks/create/review"
  15. templateUrl="https://example.com/file.json"
  16. stackName="Sentry-Monitoring-Stack"
  17. regionList={['us-east-1', 'us-west-1']}
  18. accountNumber=""
  19. region=""
  20. initialStepNumber={0}
  21. />
  22. );
  23. });
  24. it('submit arn', async () => {
  25. wrapper.find('button[name="showInputs"]').simulate('click');
  26. wrapper
  27. .find('input[name="accountNumber"]')
  28. .simulate('change', {target: {value: '599817902985'}});
  29. selectByValue(wrapper, 'us-west-1');
  30. await tick();
  31. wrapper.find('StyledButton[aria-label="Next"]').simulate('click');
  32. const {
  33. location: {origin},
  34. } = window;
  35. const query = qs.stringify({
  36. accountNumber: '599817902985',
  37. region: 'us-west-1',
  38. awsExternalId: 'my-id',
  39. });
  40. expect(windowAssignMock).toHaveBeenCalledWith(
  41. `${origin}/extensions/aws_lambda/setup/?${query}`
  42. );
  43. });
  44. });