mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-06 06:01:31 -05:00
* chore(tools): update filename and versioning API * fix(tests): rename file name * fix(tests): current version to test against
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import path from 'path';
|
|
import fs from 'fs';
|
|
import { AssertionError } from 'chai';
|
|
import envData from '../../../config/env.json';
|
|
import { SuperBlocks } from '../../../config/certification-settings';
|
|
import { mobileSchemaValidator } from './mobileSchema';
|
|
import { superBlockMobileAppOrder } from './build-external-curricula-data';
|
|
|
|
if (envData.clientLocale == 'english' && !envData.showUpcomingChanges) {
|
|
const VERSION = 'v1';
|
|
|
|
describe('mobile curriculum build', () => {
|
|
const mobileStaticPath = path.resolve(__dirname, '../../../client/static');
|
|
const blockIntroPath = path.resolve(
|
|
__dirname,
|
|
'../../../client/i18n/locales/english/intro.json'
|
|
);
|
|
|
|
const validateMobileSuperBlock = mobileSchemaValidator();
|
|
|
|
test('the mobile curriculum should have a static folder with multiple files', () => {
|
|
expect(
|
|
fs.existsSync(`${mobileStaticPath}/curriculum-data/${VERSION}`)
|
|
).toBe(true);
|
|
|
|
expect(
|
|
fs.readdirSync(`${mobileStaticPath}/curriculum-data/${VERSION}`).length
|
|
).toBeGreaterThan(0);
|
|
});
|
|
|
|
test('the mobile curriculum should have access to the intro.json file', () => {
|
|
expect(fs.existsSync(blockIntroPath)).toBe(true);
|
|
});
|
|
|
|
test('the files generated should have the correct schema', () => {
|
|
const fileArray = fs.readdirSync(
|
|
`${mobileStaticPath}/curriculum-data/${VERSION}`
|
|
);
|
|
|
|
fileArray
|
|
.filter(fileInArray => fileInArray !== 'available-superblocks.json')
|
|
.forEach(fileInArray => {
|
|
const fileContent = fs.readFileSync(
|
|
`${mobileStaticPath}/curriculum-data/${VERSION}/${fileInArray}`,
|
|
'utf-8'
|
|
);
|
|
|
|
const result = validateMobileSuperBlock(JSON.parse(fileContent));
|
|
|
|
if (result.error) {
|
|
throw new AssertionError(
|
|
result.error.toString(),
|
|
`file: ${fileInArray}`
|
|
);
|
|
}
|
|
});
|
|
});
|
|
|
|
test('All SuperBlocks should be present in the mobile SuperBlock object', () => {
|
|
expect(Object.keys(superBlockMobileAppOrder)).toEqual(
|
|
expect.arrayContaining(Object.values(SuperBlocks))
|
|
);
|
|
expect(Object.keys(superBlockMobileAppOrder)).toHaveLength(
|
|
Object.values(SuperBlocks).length
|
|
);
|
|
});
|
|
});
|
|
} else {
|
|
describe.skip('Mobile curriculum is not localized', () => {
|
|
test.todo('localized tests');
|
|
});
|
|
}
|