platform.spec.jsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. location: {query: {}},
  17. platformData: {
  18. platforms: [
  19. {
  20. id: 'csharp',
  21. name: 'C#',
  22. integrations: [
  23. {
  24. id: 'csharp',
  25. type: 'language',
  26. },
  27. ],
  28. },
  29. {
  30. id: 'javascript',
  31. name: 'JavaScript',
  32. integrations: [
  33. {
  34. id: 'javascript-react',
  35. type: 'framework',
  36. },
  37. ],
  38. },
  39. {
  40. id: 'node',
  41. name: 'Node.js',
  42. integrations: [
  43. {
  44. id: 'node',
  45. type: 'language',
  46. },
  47. {
  48. id: 'node-connect',
  49. type: 'framework',
  50. },
  51. ],
  52. },
  53. ],
  54. },
  55. };
  56. it('should render NotFound if no matching integration/platform', function() {
  57. let props = {
  58. ...baseProps,
  59. params: {
  60. platform: 'lua',
  61. },
  62. };
  63. let wrapper = shallow(<ProjectInstallPlatform {...props} />, {
  64. organization: {id: '1337'},
  65. });
  66. expect(wrapper.find('NotFound')).toHaveLength(1);
  67. });
  68. it('should rendering Loading if integration/platform exists', function() {
  69. let props = {
  70. ...baseProps,
  71. params: {
  72. platform: 'node-connect',
  73. },
  74. };
  75. let wrapper = shallow(<ProjectInstallPlatform {...props} />, {
  76. organization: {id: '1337'},
  77. });
  78. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  79. });
  80. });
  81. });