}
function getTaskComponentUrl(componentKey: string, task: Task) {
- if (task.branch && task.branchType === 'SHORT') {
- return getShortLivingBranchUrl(componentKey, task.branchType);
- } else if (task.branchType && task.branchType === 'LONG') {
- return getLongLivingBranchUrl(componentKey, task.branchType);
+ if (task.branch) {
+ if (task.branchType === 'SHORT') {
+ return getShortLivingBranchUrl(componentKey, task.branch);
+ } else if (task.branchType === 'LONG') {
+ return getLongLivingBranchUrl(componentKey, task.branch);
+ }
} else if (task.pullRequest) {
return getPullRequestUrl(componentKey, task.pullRequest);
- } else {
- return getProjectUrl(componentKey);
}
+ return getProjectUrl(componentKey);
}
import { shallow } from 'enzyme';
import TaskComponent from '../TaskComponent';
-it('renders', () => {
- const task = {
- componentKey: 'foo',
- componentName: 'foo',
- componentQualifier: 'TRK',
- id: 'bar',
- organization: 'org',
- status: 'PENDING',
- submittedAt: '2017-01-01',
- type: 'REPORT'
- };
- expect(shallow(<TaskComponent task={task} />)).toMatchSnapshot();
- expect(shallow(<TaskComponent task={{ ...task, componentKey: undefined }} />)).toMatchSnapshot();
- expect(shallow(<TaskComponent task={{ ...task, branch: 'feature' }} />)).toMatchSnapshot();
+const TASK = {
+ componentKey: 'foo',
+ componentName: 'foo',
+ componentQualifier: 'TRK',
+ id: 'bar',
+ organization: 'org',
+ status: 'PENDING',
+ submittedAt: '2017-01-01',
+ type: 'REPORT'
+};
+
+it('renders correctly', () => {
+ expect(shallow(<TaskComponent task={TASK} />)).toMatchSnapshot();
+ expect(shallow(<TaskComponent task={{ ...TASK, componentKey: undefined }} />)).toMatchSnapshot();
+});
+
+it('renders correctly for branches and pullrequest', () => {
+ expect(
+ shallow(<TaskComponent task={{ ...TASK, branch: 'feature', branchType: 'SHORT' }} />)
+ ).toMatchSnapshot();
+ expect(
+ shallow(<TaskComponent task={{ ...TASK, branch: 'branch-6.7', branchType: 'LONG' }} />)
+ ).toMatchSnapshot();
+ expect(shallow(<TaskComponent task={{ ...TASK, pullRequest: 'pr-89' }} />)).toMatchSnapshot();
});
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`renders 1`] = `
+exports[`renders correctly 1`] = `
<td>
<span
className="little-spacer-right"
</td>
`;
-exports[`renders 2`] = `
+exports[`renders correctly 2`] = `
<td>
<span
className="note"
</td>
`;
-exports[`renders 3`] = `
+exports[`renders correctly for branches and pullrequest 1`] = `
<td>
- <span
+ <ShortLivingBranchIcon
className="little-spacer-right"
- >
- <QualifierIcon
- qualifier="TRK"
- />
- </span>
+ />
<Connect(Organization)
organizationKey="org"
/>
style={Object {}}
to={
Object {
- "pathname": "/dashboard",
+ "pathname": "/project/issues",
"query": Object {
+ "branch": "feature",
"id": "foo",
+ "resolved": "false",
},
}
}
/>
</td>
`;
+
+exports[`renders correctly for branches and pullrequest 2`] = `
+<td>
+ <LongLivingBranchIcon
+ className="little-spacer-right"
+ />
+ <Connect(Organization)
+ organizationKey="org"
+ />
+ <Link
+ className="spacer-right"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/dashboard",
+ "query": Object {
+ "branch": "branch-6.7",
+ "id": "foo",
+ },
+ }
+ }
+ >
+ foo
+ <span
+ className="text-limited text-text-top"
+ title="branch-6.7"
+ >
+ <span
+ style={
+ Object {
+ "marginLeft": 5,
+ "marginRight": 5,
+ }
+ }
+ >
+ /
+ </span>
+ branch-6.7
+ </span>
+ </Link>
+ <TaskType
+ type="REPORT"
+ />
+</td>
+`;
+
+exports[`renders correctly for branches and pullrequest 3`] = `
+<td>
+ <PullRequestIcon
+ className="little-spacer-right"
+ />
+ <Connect(Organization)
+ organizationKey="org"
+ />
+ <Link
+ className="spacer-right"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/project/issues",
+ "query": Object {
+ "id": "foo",
+ "pullRequest": "pr-89",
+ "resolved": "false",
+ },
+ }
+ }
+ >
+ foo
+ <Tooltip>
+ <span
+ className="text-limited text-text-top"
+ >
+ <span
+ style={
+ Object {
+ "marginLeft": 5,
+ "marginRight": 5,
+ }
+ }
+ >
+ /
+ </span>
+ pr-89
+ </span>
+ </Tooltip>
+ </Link>
+ <TaskType
+ type="REPORT"
+ />
+</td>
+`;