platform.spec.jsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {browserHistory} from 'react-router';
  2. import React from 'react';
  3. import {shallow, mountWithTheme} from 'sentry-test/enzyme';
  4. import {ProjectInstallPlatform} from 'app/views/projectInstall/platform';
  5. describe('ProjectInstallPlatform', function() {
  6. describe('render()', function() {
  7. const baseProps = {
  8. api: new MockApiClient(),
  9. organization: TestStubs.Organization(),
  10. project: TestStubs.Project(),
  11. location: {query: {}},
  12. };
  13. it('should redirect to if no matching platform', function() {
  14. const props = {
  15. ...baseProps,
  16. params: {
  17. orgId: baseProps.organization.slug,
  18. projectId: baseProps.project.slug,
  19. platform: 'other',
  20. },
  21. };
  22. MockApiClient.addMockResponse({
  23. url: '/projects/org-slug/project-slug/docs/other/',
  24. body: {},
  25. });
  26. mountWithTheme(
  27. <ProjectInstallPlatform {...props} />,
  28. TestStubs.routerContext([{organization: {id: '1337'}}])
  29. );
  30. expect(browserHistory.push).toHaveBeenCalledTimes(1);
  31. });
  32. it('should render NotFound if no matching integration/platform', async function() {
  33. const props = {
  34. ...baseProps,
  35. params: {
  36. platform: 'lua',
  37. },
  38. };
  39. const wrapper = shallow(
  40. <ProjectInstallPlatform {...props} />,
  41. TestStubs.routerContext([{organization: {id: '1337'}}])
  42. );
  43. await tick();
  44. wrapper.update();
  45. expect(wrapper.find('NotFound')).toHaveLength(1);
  46. });
  47. it('should rendering Loading if integration/platform exists', function() {
  48. const props = {
  49. ...baseProps,
  50. params: {
  51. platform: 'node-connect',
  52. },
  53. };
  54. const wrapper = shallow(
  55. <ProjectInstallPlatform {...props} />,
  56. TestStubs.routerContext([{organization: {id: '1337'}}])
  57. );
  58. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  59. });
  60. it('should render documentation', async function() {
  61. const props = {
  62. ...baseProps,
  63. params: {
  64. orgId: baseProps.organization.slug,
  65. projectId: baseProps.project.slug,
  66. platform: 'node',
  67. },
  68. };
  69. MockApiClient.addMockResponse({
  70. url: '/projects/org-slug/project-slug/docs/node/',
  71. body: {html: '<h1>Documentation here</h1>'},
  72. });
  73. const wrapper = mountWithTheme(
  74. <ProjectInstallPlatform {...props} />,
  75. TestStubs.routerContext([{organization: {id: '1337'}}])
  76. );
  77. await tick();
  78. wrapper.update();
  79. expect(wrapper.find('DocumentationWrapper')).toHaveLength(1);
  80. expect(wrapper.find('DocumentationWrapper').text()).toBe('Documentation here');
  81. });
  82. });
  83. });