platform.spec.jsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. projectId: baseProps.project.slug,
  17. platform: 'other',
  18. },
  19. };
  20. MockApiClient.addMockResponse({
  21. url: '/projects/org-slug/project-slug/docs/other/',
  22. body: {},
  23. });
  24. render(<ProjectInstallPlatform {...props} />, {
  25. context: TestStubs.routerContext([{organization: {id: '1337'}}]),
  26. });
  27. expect(browserHistory.push).toHaveBeenCalledTimes(1);
  28. });
  29. it('should render NotFound if no matching integration/platform', async function () {
  30. const props = {
  31. ...baseProps,
  32. params: {
  33. projectId: baseProps.project.slug,
  34. platform: 'lua',
  35. },
  36. };
  37. MockApiClient.addMockResponse({
  38. url: '/projects/org-slug/project-slug/docs/lua/',
  39. statusCode: 404,
  40. });
  41. render(<ProjectInstallPlatform {...props} />, {
  42. context: TestStubs.routerContext([{organization: {id: '1337'}}]),
  43. });
  44. expect(await screen.findByText('Page Not Found')).toBeInTheDocument();
  45. });
  46. it('should render documentation', async function () {
  47. const props = {
  48. ...baseProps,
  49. params: {
  50. projectId: baseProps.project.slug,
  51. platform: 'node',
  52. },
  53. };
  54. MockApiClient.addMockResponse({
  55. url: '/projects/org-slug/project-slug/docs/node/',
  56. body: {html: '<h1>Documentation here</h1>'},
  57. });
  58. render(<ProjectInstallPlatform {...props} />, {
  59. context: TestStubs.routerContext([{organization: {id: '1337'}}]),
  60. });
  61. expect(await screen.findByText('Documentation here')).toBeInTheDocument();
  62. });
  63. });
  64. });