123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import React from 'react';
- import {mount} from 'sentry-test/enzyme';
- import PullRequestLink from 'app/components/pullRequestLink';
- describe('PullRequestLink', function() {
- it('renders no url on missing externalUrl', function() {
- const repository = TestStubs.Repository({provider: null});
- const pullRequest = TestStubs.PullRequest({
- repository,
- externalUrl: null,
- });
- const wrapper = mount(
- <PullRequestLink repository={repository} pullRequest={pullRequest} />
- );
- expect(wrapper.find('a')).toHaveLength(0);
- expect(wrapper.find('span').text()).toEqual('example/repo-name #3: Fix first issue');
- });
- it('renders github links for integrations:github repositories', function() {
- const repository = TestStubs.Repository({
- provider: {
- id: 'integrations:github',
- },
- });
- const pullRequest = TestStubs.PullRequest({repository});
- const wrapper = mount(
- <PullRequestLink repository={repository} pullRequest={pullRequest} />
- );
- const icon = wrapper.find('InlineSvg');
- expect(icon).toHaveLength(1);
- expect(icon.props().src).toEqual('icon-github');
- const link = wrapper.find('a');
- expect(link).toHaveLength(1);
- expect(link.text().trim()).toEqual('example/repo-name #3: Fix first issue');
- });
- it('renders github links for github repositories', function() {
- const repository = TestStubs.Repository({
- provider: {
- id: 'github',
- },
- });
- const pullRequest = TestStubs.PullRequest({repository});
- const wrapper = mount(
- <PullRequestLink repository={repository} pullRequest={pullRequest} />
- );
- const icon = wrapper.find('InlineSvg');
- expect(icon).toHaveLength(1);
- expect(icon.props().src).toEqual('icon-github');
- const link = wrapper.find('a');
- expect(link).toHaveLength(1);
- expect(link.text().trim()).toEqual('example/repo-name #3: Fix first issue');
- });
- it('renders gitlab links for integrations:gitlab repositories', function() {
- const repository = TestStubs.Repository({
- provider: {
- id: 'integrations:gitlab',
- },
- });
- const pullRequest = TestStubs.PullRequest({repository});
- const wrapper = mount(
- <PullRequestLink repository={repository} pullRequest={pullRequest} />
- );
- const icon = wrapper.find('InlineSvg');
- expect(icon).toHaveLength(1);
- expect(icon.props().src).toEqual('icon-gitlab');
- const link = wrapper.find('a');
- expect(link).toHaveLength(1);
- expect(link.text().trim()).toEqual('example/repo-name #3: Fix first issue');
- });
- it('renders github links for gitlab repositories', function() {
- const repository = TestStubs.Repository({
- provider: {
- id: 'gitlab',
- },
- });
- const pullRequest = TestStubs.PullRequest({repository});
- const wrapper = mount(
- <PullRequestLink repository={repository} pullRequest={pullRequest} />
- );
- const icon = wrapper.find('InlineSvg');
- expect(icon).toHaveLength(1);
- expect(icon.props().src).toEqual('icon-gitlab');
- const link = wrapper.find('a');
- expect(link).toHaveLength(1);
- expect(link.text().trim()).toEqual('example/repo-name #3: Fix first issue');
- });
- });
|