version.spec.jsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react';
  2. import {mount} from 'sentry-test/enzyme';
  3. import Version from 'app/components/version';
  4. const VERSION = 'foo.bar.Baz@1.0.0+20200101';
  5. describe('Version', () => {
  6. const routerContext = TestStubs.routerContext();
  7. it('renders', () => {
  8. const wrapper = mount(<Version version={VERSION} />, routerContext);
  9. expect(wrapper).toSnapshot();
  10. });
  11. it('shows correct parsed version', () => {
  12. // component uses @sentry/release-parser package for parsing versions
  13. const wrapper = mount(<Version version={VERSION} />, routerContext);
  14. expect(wrapper.text()).toBe('1.0.0 (20200101)');
  15. });
  16. it('links to release page', () => {
  17. const wrapper = mount(<Version version={VERSION} projectId="1" />, routerContext);
  18. expect(wrapper.find('Link').first().prop('to')).toEqual({
  19. pathname: '/organizations/org-slug/releases/foo.bar.Baz%401.0.0%2B20200101/',
  20. query: {project: '1'},
  21. });
  22. });
  23. it('shows raw version in tooltip', () => {
  24. const wrapper = mount(<Version version={VERSION} tooltipRawVersion />, routerContext);
  25. const tooltipContent = mount(wrapper.find('Tooltip').prop('title'));
  26. expect(tooltipContent.text()).toBe(VERSION);
  27. });
  28. });