chore(tools): test intro file structure (#50175)

This commit is contained in:
Naomi Carrigan
2023-04-24 23:36:06 -07:00
committed by GitHub
parent 6cbd6be1e5
commit a272028a40
+30
View File
@@ -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);
});
}
});