mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore(tools): test intro file structure (#50175)
This commit is contained in:
@@ -1,9 +1,24 @@
|
||||
import fs from 'fs';
|
||||
import { setup } from 'jest-json-schema-extended';
|
||||
import { availableLangs, LangNames, LangCodes } from '../../config/i18n';
|
||||
import { SuperBlocks } from '../../config/certification-settings';
|
||||
import intro from './locales/english/intro.json';
|
||||
|
||||
setup();
|
||||
|
||||
interface Intro {
|
||||
[key: string]: {
|
||||
title: string;
|
||||
intro: string[];
|
||||
blocks: {
|
||||
[block: string]: {
|
||||
title: string;
|
||||
intro: string[];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
const filesThatShouldExist = [
|
||||
{
|
||||
name: 'translations.json'
|
||||
@@ -53,3 +68,18 @@ describe('Locale tests:', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Intro file structure tests:', () => {
|
||||
const typedIntro = intro as unknown as Intro;
|
||||
const superblocks = Object.values(SuperBlocks);
|
||||
for (const superBlock of superblocks) {
|
||||
expect(typeof typedIntro[superBlock].title).toBe('string');
|
||||
expect(typedIntro[superBlock].intro).toBeInstanceOf(Array);
|
||||
expect(typedIntro[superBlock].blocks).toBeInstanceOf(Object);
|
||||
const blocks = Object.keys(typedIntro[superBlock].blocks);
|
||||
blocks.forEach(block => {
|
||||
expect(typeof typedIntro[superBlock].blocks[block].title).toBe('string');
|
||||
expect(typedIntro[superBlock].blocks[block].intro).toBeInstanceOf(Array);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user