welcome.spec.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import OnboardingWelcome from 'app/views/onboarding/welcome';
  4. import ConfigStore from 'app/stores/configStore';
  5. describe('OnboardingWelcome', function() {
  6. it('renders', function() {
  7. const name = 'Rick Snachez';
  8. ConfigStore.loadInitialData({user: {name, options: {}}});
  9. const wrapper = mount(<OnboardingWelcome />, TestStubs.routerContext());
  10. expect(
  11. wrapper
  12. .find('p')
  13. .first()
  14. .text()
  15. ).toEqual(expect.stringContaining('Rick'));
  16. });
  17. it('calls onComplete when progressing', function() {
  18. const onComplete = jest.fn();
  19. const wrapper = mount(
  20. <OnboardingWelcome active onComplete={onComplete} />,
  21. TestStubs.routerContext()
  22. );
  23. wrapper
  24. .find('Button[priority="primary"]')
  25. .first()
  26. .simulate('click');
  27. expect(onComplete).toHaveBeenCalled();
  28. });
  29. it('disables the next step button when it is not active', function() {
  30. const onComplete = jest.fn();
  31. const wrapper = mount(
  32. <OnboardingWelcome onComplete={onComplete} />,
  33. TestStubs.routerContext()
  34. );
  35. wrapper
  36. .find('Button[priority="primary"]')
  37. .first()
  38. .simulate('click');
  39. expect(onComplete).not.toHaveBeenCalled();
  40. });
  41. });