platform.spec.jsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import {browserHistory} from 'react-router';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import {ProjectInstallPlatform} from 'sentry/views/projectInstall/platform';
  4. describe('ProjectInstallPlatform', function () {
  5. describe('render()', function () {
  6. const baseProps = {
  7. api: new MockApiClient(),
  8. organization: TestStubs.Organization(),
  9. project: TestStubs.Project(),
  10. location: {query: {}},
  11. };
  12. it('should redirect to if no matching platform', function () {
  13. const props = {
  14. ...baseProps,
  15. params: {
  16. orgId: baseProps.organization.slug,
  17. projectId: baseProps.project.slug,
  18. platform: 'other',
  19. },
  20. };
  21. MockApiClient.addMockResponse({
  22. url: '/projects/org-slug/project-slug/docs/other/',
  23. body: {},
  24. });
  25. render(<ProjectInstallPlatform {...props} />, {
  26. context: TestStubs.routerContext([{organization: {id: '1337'}}]),
  27. });
  28. expect(browserHistory.push).toHaveBeenCalledTimes(1);
  29. });
  30. it('should render NotFound if no matching integration/platform', async function () {
  31. const props = {
  32. ...baseProps,
  33. params: {
  34. orgId: baseProps.organization.slug,
  35. projectId: baseProps.project.slug,
  36. platform: 'lua',
  37. },
  38. };
  39. MockApiClient.addMockResponse({
  40. url: '/projects/org-slug/project-slug/docs/lua/',
  41. statusCode: 404,
  42. });
  43. render(<ProjectInstallPlatform {...props} />, {
  44. context: TestStubs.routerContext([{organization: {id: '1337'}}]),
  45. });
  46. expect(await screen.findByText('Page Not Found')).toBeInTheDocument();
  47. });
  48. it('should render documentation', async function () {
  49. const props = {
  50. ...baseProps,
  51. params: {
  52. orgId: baseProps.organization.slug,
  53. projectId: baseProps.project.slug,
  54. platform: 'node',
  55. },
  56. };
  57. MockApiClient.addMockResponse({
  58. url: '/projects/org-slug/project-slug/docs/node/',
  59. body: {html: '<h1>Documentation here</h1>'},
  60. });
  61. render(<ProjectInstallPlatform {...props} />, {
  62. context: TestStubs.routerContext([{organization: {id: '1337'}}]),
  63. });
  64. expect(await screen.findByText('Documentation here')).toBeInTheDocument();
  65. });
  66. });
  67. });