projectLink.spec.jsx 1.1 KB

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