Commit d4e88f6b authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Added additional specs

parent f9c64e5b
......@@ -2,9 +2,8 @@
import Api from 'ee/api';
import { __ } from '~/locale';
import createFlash from '~/flash';
import { slugify } from '~/lib/utils/text_utility';
import MetricCard from '../../shared/components/metric_card.vue';
import { removeFlash } from '../utils';
import { removeFlash, prepareTimeMetricsData } from '../utils';
export default {
name: 'RecentActivityCard',
......@@ -45,11 +44,7 @@ export default {
this.additionalParams ? this.additionalParams : {},
)
.then(({ data }) => {
this.data = data.map(({ title: label, value }) => ({
value: value || '-',
label,
key: slugify(label),
}));
this.data = prepareTimeMetricsData(data);
})
.catch(() => {
createFlash(
......
import { isNumber } from 'lodash';
import { getDatesInRange } from '~/lib/utils/datetime_utility';
import { slugify } from '~/lib/utils/text_utility';
import {
isStartEvent,
isLabelEvent,
......@@ -322,6 +323,7 @@ describe('Cycle analytics utils', () => {
it('will remove an id that exists', () => {
expect(toggleSelectedLabel({ selectedLabelIds, value: 2 })).toEqual([1, 3]);
});
it('will add an id that does not exist', () => {
expect(toggleSelectedLabel({ selectedLabelIds, value: 4 })).toEqual([1, 2, 3, 4]);
});
......@@ -373,27 +375,25 @@ describe('Cycle analytics utils', () => {
describe('prepareTimeMetricsData', () => {
let prepared;
const [{ title: firstTitle }, { title: secondTitle }] = timeMetricsData;
const firstKey = slugify(firstTitle);
const secondKey = slugify(secondTitle);
beforeEach(() => {
prepared = prepareTimeMetricsData(timeMetricsData);
prepared = prepareTimeMetricsData(timeMetricsData, {
[firstKey]: 'Is a value that is good',
});
});
it('will add a `key` based on the title', () => {
expect(timeMetricsData).not.toMatchObject([{ key: 'lead-time' }, { key: 'cycle-time' }]);
expect(prepared).toMatchObject([{ key: 'lead-time' }, { key: 'cycle-time' }]);
expect(prepared).toMatchObject([{ key: firstKey }, { key: secondKey }]);
});
it('will replace the title with a `label` key', () => {
expect(timeMetricsData).not.toMatchObject([{ label: 'Lead Time' }, { label: 'Cycle Time' }]);
it('will add a `label` key', () => {
expect(prepared).toMatchObject([{ label: 'Lead Time' }, { label: 'Cycle Time' }]);
});
it('will add tooltip text using the key if it is provided', () => {
prepared = prepareTimeMetricsData(timeMetricsData, {
'lead-time': 'Is a value that is good',
});
expect(timeMetricsData).not.toMatchObject([{ tooltipText: 'Is a value that is good' }]);
it('will add a tooltip text using the key if it is provided', () => {
expect(prepared).toMatchObject([
{ tooltipText: 'Is a value that is good' },
{ tooltipText: '' },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment