globalSelectionLink.spec.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React from 'react';
  2. import {shallow} from 'enzyme';
  3. import GlobalSelectionLink from 'app/components/globalSelectionLink';
  4. const path = 'http://some.url/';
  5. describe('GlobalSelectionLink', function() {
  6. it('has global selection values in query', function() {
  7. const query = {
  8. project: ['foo', 'bar'],
  9. environment: 'staging',
  10. };
  11. const wrapper = shallow(
  12. <GlobalSelectionLink to={path}>Go somewhere!</GlobalSelectionLink>,
  13. {
  14. context: {
  15. location: {
  16. query,
  17. },
  18. },
  19. }
  20. );
  21. const updatedToProp = wrapper.find('Link').prop('to');
  22. expect(updatedToProp).toEqual({pathname: path, query});
  23. expect(wrapper).toMatchSnapshot();
  24. });
  25. it('does not have global selection values in query', function() {
  26. const wrapper = shallow(
  27. <GlobalSelectionLink to={path}>Go somewhere!</GlobalSelectionLink>,
  28. {
  29. context: {
  30. location: {
  31. query: {},
  32. },
  33. },
  34. }
  35. );
  36. const updatedToProp = wrapper.find('Link').prop('to');
  37. expect(updatedToProp).toEqual(path);
  38. expect(wrapper).toMatchSnapshot();
  39. });
  40. });