pipelineView.spec.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import PipelineView from 'sentry/views/integrationPipeline/pipelineView';
  3. function MockAwsLambdaProjectSelect() {
  4. return <div>mock_AwsLambdaProjectSelect</div>;
  5. }
  6. jest.mock(
  7. 'sentry/views/integrationPipeline/awsLambdaProjectSelect',
  8. () => MockAwsLambdaProjectSelect
  9. );
  10. describe('PipelineView', () => {
  11. afterEach(() => {
  12. jest.restoreAllMocks();
  13. });
  14. it('renders awsLambdaProjectSelect', () => {
  15. render(<PipelineView pipelineName="awsLambdaProjectSelect" someField="someVal" />, {
  16. // XXX(epurkhiser): The pipeline view renders a Router inside of it. Stop
  17. // our test renderer from rendering it's Router by setting the wrapper to
  18. // undefined.
  19. wrapper: undefined,
  20. });
  21. expect(screen.getByText('mock_AwsLambdaProjectSelect')).toBeInTheDocument();
  22. expect(document.title).toBe('AWS Lambda Select Project');
  23. });
  24. it('errros on invalid pipelineName', () => {
  25. jest.spyOn(console, 'error').mockImplementation(() => {});
  26. expect(() =>
  27. render(<PipelineView pipelineName="other" />, {
  28. // XXX(epurkhiser): The pipeline view renders a Router inside of it. Stop
  29. // our test renderer from rendering it's Router by setting the wrapper to
  30. // undefined.
  31. wrapper: undefined,
  32. })
  33. ).toThrow('Invalid pipeline name other');
  34. });
  35. });