Commit cdd10bf7 authored by Alexander Turinske's avatar Alexander Turinske

Update code to use less CSS

- use humanize method to prepare strings
- remove unnecessary backticks
parent 17aa74e4
import { REPORT_TYPES } from 'ee/security_dashboard/store/constants';
import { humanize } from '~/lib/utils/text_utility';
/**
* Takes the report type, that is not human-readable and converts it to be human-readable
* @param {string} reportType that is not human-readable
* @returns {string} the conversion from REPORT_TYPES or a lowercase version without '_' in it to
* be paired with the CSS class `text-capitalize`
* @returns {string} a human-readable version of the report type
*/
const convertReportType = reportType => {
if (!reportType) return '';
const lowerCaseType = reportType.toLowerCase();
return REPORT_TYPES[lowerCaseType] || lowerCaseType.split('_').join(' ');
return REPORT_TYPES[lowerCaseType] || humanize(lowerCaseType);
};
export default convertReportType;
......@@ -112,7 +112,7 @@ export default {
key: 'reportType',
class: this.reportTypeClass,
label: s__('Reports|Scanner'),
thClass: `${commonThClass}`,
thClass: commonThClass,
},
];
},
......
......@@ -50,9 +50,9 @@ describe('security reports utils', () => {
['sast', 'SAST'],
['dependency_scanning', 'Dependency Scanning'],
['CONTAINER_SCANNING', 'Container Scanning'],
['CUSTOM_SCANNER', 'custom scanner'],
['mast', 'mast'],
['TAST', 'tast'],
['CUSTOM_SCANNER', 'Custom scanner'],
['mast', 'Mast'],
['TAST', 'Tast'],
[undefined, ''],
])('converts the report type "%s" to the human-readable string "%s"', (input, output) => {
expect(convertReportType(input)).toEqual(output);
......
......@@ -194,7 +194,7 @@ describe('Vulnerability list component', () => {
const cells = findCells('reportType');
expect(cells.wrappers[0].text()).toBe('SAST');
expect(cells.wrappers[1].text()).toBe('Dependency Scanning');
expect(cells.wrappers[2].text()).toBe('custom scanner without translation');
expect(cells.wrappers[2].text()).toBe('Custom scanner without translation');
expect(cells.wrappers[3].text()).toBe('');
});
});
......
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