platform.spec.jsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import React from 'react';
  2. import {shallow} from 'enzyme';
  3. import {Client} from 'app/api';
  4. import {ProjectInstallPlatform} from 'app/views/projectInstall/platform';
  5. describe('ProjectInstallPlatform', function() {
  6. let sandbox;
  7. beforeEach(function() {
  8. sandbox = sinon.sandbox.create();
  9. this.stubbedApiRequest = sandbox.stub(Client.prototype, 'request');
  10. });
  11. afterEach(function() {
  12. sandbox.restore();
  13. });
  14. describe('render()', function() {
  15. const baseProps = {
  16. organization: TestStubs.Organization(),
  17. location: {query: {}},
  18. platformData: {
  19. platforms: [
  20. {
  21. id: 'csharp',
  22. name: 'C#',
  23. integrations: [
  24. {
  25. id: 'csharp',
  26. type: 'language',
  27. },
  28. ],
  29. },
  30. {
  31. id: 'javascript',
  32. name: 'JavaScript',
  33. integrations: [
  34. {
  35. id: 'javascript-react',
  36. type: 'framework',
  37. },
  38. ],
  39. },
  40. {
  41. id: 'node',
  42. name: 'Node.js',
  43. integrations: [
  44. {
  45. id: 'node',
  46. type: 'language',
  47. },
  48. {
  49. id: 'node-connect',
  50. type: 'framework',
  51. },
  52. ],
  53. },
  54. ],
  55. },
  56. };
  57. it('should render NotFound if no matching integration/platform', function() {
  58. let props = {
  59. ...baseProps,
  60. params: {
  61. platform: 'lua',
  62. },
  63. };
  64. let wrapper = shallow(<ProjectInstallPlatform {...props} />, {
  65. organization: {id: '1337'},
  66. });
  67. expect(wrapper.find('NotFound')).toHaveLength(1);
  68. });
  69. it('should rendering Loading if integration/platform exists', function() {
  70. let props = {
  71. ...baseProps,
  72. params: {
  73. platform: 'node-connect',
  74. },
  75. };
  76. let wrapper = shallow(<ProjectInstallPlatform {...props} />, {
  77. organization: {id: '1337'},
  78. });
  79. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  80. });
  81. });
  82. });