refactor: use cert-slugs where possible (#57505)

This commit is contained in:
Oliver Eyton-Williams
2024-12-13 22:15:41 +01:00
committed by GitHub
parent cf18718fcc
commit 1690afeb95
10 changed files with 165 additions and 270 deletions
@@ -1,34 +0,0 @@
import { uniq } from 'lodash';
import {
currentCertifications,
upcomingCertifications,
legacyCertifications
} from '../../shared/config/certification-settings';
import {
currentCertTitles,
upcomingCertTitles,
legacyCertTitles
} from './cert-and-project-map';
describe('cert-and-project-map', () => {
describe('currentCertTitles', () => {
it('should correspond to the currentCertifications config', () => {
expect(currentCertTitles).toHaveLength(uniq(currentCertTitles).length);
expect(currentCertTitles).toHaveLength(currentCertifications.length);
});
});
describe('upcomingCertTitles', () => {
it('should correspond to the upcomingCertifications config', () => {
expect(upcomingCertTitles).toHaveLength(uniq(upcomingCertTitles).length);
expect(upcomingCertTitles).toHaveLength(upcomingCertifications.length);
});
});
describe('legacyCertTitles', () => {
it('should correspond to the legacyCertifications config', () => {
expect(legacyCertTitles).toHaveLength(uniq(legacyCertTitles).length);
expect(legacyCertTitles).toHaveLength(legacyCertifications.length);
});
});
});
+3 -13
View File
@@ -881,29 +881,19 @@ const liveCerts = showUpcomingChanges
: [...currentCerts, ...legacyCerts, fullstackCert];
type CertsToProjects = Record<
(typeof allStandardCerts)[number]['title'],
(typeof allStandardCerts)[number]['certSlug'],
(typeof allStandardCerts)[number]['projects']
>;
const certsToProjects = allStandardCerts.reduce((acc, curr) => {
return {
...acc,
[curr.title]: curr.projects
[curr.certSlug]: curr.projects
};
}, {} as CertsToProjects);
const currentCertTitles = currentCerts.map(({ title }) => title);
const legacyCertTitles = legacyCerts.map(({ title }) => title);
const upcomingCertTitles = upcomingCerts.map(({ title }) => title);
export type CertTitle =
| (typeof liveCerts)[number]['title']
| 'Legacy Full Stack';
export {
currentCertTitles,
legacyCertTitles,
upcomingCertTitles,
liveCerts,
certsToProjects
};
export { liveCerts, certsToProjects };