freeCodeCamp/shared/config/curriculum.test.ts
Tom 3af161450f
Some checks failed
CI - E2E - 3rd party donation tests / Build Client (22) (push) Has been cancelled
CI - E2E - 3rd party donation tests / Build API (Container) (push) Has been cancelled
CI - Node.js / Lint (22) (push) Has been cancelled
CI - E2E - 3rd party donation tests / Run Playwright 3rd Party Donation Tests (chromium, 22) (push) Has been cancelled
CI - Node.js / Build (22) (push) Has been cancelled
CI - Node.js / Test (22) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (22) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 22) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 22) (push) Has been cancelled
feat(curriculum, client): add catalog (#60951)
2025-06-26 15:08:36 -05:00

76 lines
2.4 KiB
TypeScript

import { Languages } from './i18n';
import {
SuperBlocks,
SuperBlockStage,
superBlockStages,
notAuditedSuperBlocks,
generateSuperBlockList,
getAuditedSuperBlocks
} from './curriculum';
describe('superBlockOrder', () => {
it('should contain all SuperBlocks', () => {
const allSuperBlocks = Object.values(SuperBlocks);
const superBlockOrderValues = Object.values(superBlockStages).flat();
expect(superBlockOrderValues).toHaveLength(allSuperBlocks.length);
expect(superBlockOrderValues).toEqual(
expect.arrayContaining(allSuperBlocks)
);
});
});
describe('generateSuperBlockList', () => {
it('should return an array of SuperBlocks object with all elements when if all configs are true', () => {
const result = generateSuperBlockList({
showUpcomingChanges: true
});
expect(result).toHaveLength(Object.values(superBlockStages).flat().length);
});
it('should return an array of SuperBlocks without Upcoming when { showUpcomingChanges: false }', () => {
const result = generateSuperBlockList({
showUpcomingChanges: false
});
const tempSuperBlockMap = { ...superBlockStages };
tempSuperBlockMap[SuperBlockStage.Upcoming] = [];
tempSuperBlockMap[SuperBlockStage.Catalog] = [];
expect(result).toHaveLength(Object.values(tempSuperBlockMap).flat().length);
});
});
describe('Immutability of superBlockOrder, notAuditedSuperBlocks, and flatSuperBlockMap', () => {
it('should not allow modification of superBlockOrder', () => {
expect(() => {
superBlockStages[SuperBlockStage.Core] = [];
}).toThrow(TypeError);
});
it('should not allow modification of notAuditedSuperBlocks', () => {
expect(() => {
notAuditedSuperBlocks[Languages.English] = [];
}).toThrow(TypeError);
});
it('should not allow modification of flatSuperBlockMap', () => {
expect(() => {
notAuditedSuperBlocks[Languages.English] = [];
}).toThrow(TypeError);
});
});
describe('getAuditedSuperBlocks', () => {
Object.keys(notAuditedSuperBlocks).forEach(language => {
it(`should return only audited SuperBlocks for ${language}`, () => {
const auditedSuperBlocks = getAuditedSuperBlocks({
language
});
auditedSuperBlocks.forEach(superblock => {
expect(notAuditedSuperBlocks[language as Languages]).not.toContain(
superblock
);
});
});
});
});