Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
jest.mock('@modules/analyze/components/CardDropDownMenu', () => ({
__esModule: true,
default: () => null,
}));

import { getChartTabs } from './BugIssueOpenTime';

describe('getChartTabs', () => {
it('plots the bug-issue open time series, not the all-issue one', () => {
const tabs = getChartTabs((key) => key);
expect(tabs['1'].yKey).toBe('metricCommunity.bugIssueOpenTimeAvg');
expect(tabs['2'].yKey).toBe('metricCommunity.bugIssueOpenTimeMid');
expect(tabs['1'].summaryKey).toBe('summaryCommunity.bugIssueOpenTimeAvg');
expect(tabs['2'].summaryKey).toBe('summaryCommunity.bugIssueOpenTimeMid');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ import { DataContainerResult } from '@modules/analyze/type';
import CardDropDownMenu from '@modules/analyze/components/CardDropDownMenu';
import { toTransString } from '@common/utils';

export const getChartTabs = (t: (key: string) => string) => ({
'1': {
legendName: t('analyze:average'),
xKey: 'grimoireCreationDate',
yKey: 'metricCommunity.bugIssueOpenTimeAvg',
summaryKey: 'summaryCommunity.bugIssueOpenTimeAvg',
},
'2': {
legendName: t('analyze:median'),
xKey: 'grimoireCreationDate',
yKey: 'metricCommunity.bugIssueOpenTimeMid',
summaryKey: 'summaryCommunity.bugIssueOpenTimeMid',
},
});
const BugIssueOpenTime = () => {
const { t, i18n } = useTranslation();

Expand All @@ -22,20 +36,7 @@ const BugIssueOpenTime = () => {
{ label: t('analyze:median'), value: '2' },
];

const chartTabs = {
'1': {
legendName: t('analyze:average'),
xKey: 'grimoireCreationDate',
yKey: 'metricCommunity.issueOpenTimeAvg',
summaryKey: 'summaryCommunity.issueOpenTimeAvg',
},
'2': {
legendName: t('analyze:median'),
xKey: 'grimoireCreationDate',
yKey: 'metricCommunity.issueOpenTimeMid',
summaryKey: 'summaryCommunity.issueOpenTimeMid',
},
};
const chartTabs = getChartTabs(t);

const [tab, setTab] = useState<TabValue>('1');
type TabValue = keyof typeof chartTabs;
Expand Down