awsLambdaProjectSelect.spec.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import {ProjectFixture} from 'sentry-fixture/project';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import selectEvent from 'sentry-test/selectEvent';
  4. import type {Project} from 'sentry/types/project';
  5. import AwsLambdaProjectSelect from 'sentry/views/integrationPipeline/awsLambdaProjectSelect';
  6. describe('AwsLambdaProjectSelect', () => {
  7. let projects: Project[];
  8. let windowAssignMock: jest.Mock;
  9. beforeEach(() => {
  10. windowAssignMock = jest.fn();
  11. window.location.assign = windowAssignMock;
  12. projects = [
  13. ProjectFixture(),
  14. ProjectFixture({id: '53', name: 'My Proj', slug: 'my-proj'}),
  15. ];
  16. });
  17. it('submit project', async () => {
  18. render(<AwsLambdaProjectSelect projects={projects} />);
  19. await selectEvent.select(screen.getByRole('textbox'), 'my-proj');
  20. await userEvent.click(screen.getByRole('button', {name: 'Next'}));
  21. expect(windowAssignMock).toHaveBeenCalledWith(
  22. `${window.location.origin}/extensions/aws_lambda/setup/?projectId=53`
  23. );
  24. });
  25. });