index.spec.jsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import {shallow, mount} from 'enzyme';
  4. import {Client} from 'app/api';
  5. import OnboardingWizard from 'app/views/onboarding/';
  6. import Project from 'app/views/onboarding/project';
  7. describe('OnboardingWizard', function() {
  8. let sandbox;
  9. beforeEach(function() {
  10. sandbox = sinon.sandbox.create();
  11. this.stubbedApiRequest = sandbox.stub(Client.prototype, 'request');
  12. });
  13. afterEach(function() {
  14. sandbox.restore();
  15. });
  16. describe('render()', function() {
  17. const baseProps = {
  18. location: {query: {}},
  19. params: {
  20. projectId: '',
  21. orgId: 'testOrg',
  22. },
  23. };
  24. it('should render NotFound if no matching organization', function() {
  25. let props = {
  26. ...baseProps,
  27. params: {
  28. orgId: 'my-cool-org',
  29. },
  30. };
  31. let wrapper = shallow(<OnboardingWizard {...props} />, {
  32. organization: {id: '1337', slug: 'testOrg'},
  33. });
  34. expect(wrapper).toMatchSnapshot();
  35. });
  36. it('should render and respond to click events', function() {
  37. let props = {
  38. ...baseProps,
  39. children: (
  40. <Project
  41. next={jest.fn()}
  42. platform={''}
  43. setName={jest.fn()}
  44. name={''}
  45. setPlatform={jest.fn()}
  46. />
  47. ),
  48. };
  49. let wrapper = mount(<OnboardingWizard {...props} />, {
  50. context: {
  51. organization: {id: '1337', slug: 'testOrg'},
  52. router: TestStubs.router(),
  53. },
  54. childContextTypes: {
  55. router: PropTypes.object,
  56. organization: PropTypes.object,
  57. },
  58. });
  59. expect(wrapper).toMatchSnapshot();
  60. let node = wrapper.find('PlatformCard').first();
  61. node.props().onClick();
  62. expect(wrapper).toMatchSnapshot();
  63. });
  64. });
  65. });