mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 18:18:27 -05:00
feat: challenge helpers for non-step-based challenges (#50769)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
@@ -22,7 +22,12 @@ jest.mock('./helpers/get-step-template', () => {
|
||||
|
||||
const mockChallengeId = '60d35cf3fe32df2ce8e31b03';
|
||||
import { getStepTemplate } from './helpers/get-step-template';
|
||||
import { createStepFile, insertStepIntoMeta, updateStepTitles } from './utils';
|
||||
import {
|
||||
createChallengeFile,
|
||||
createStepFile,
|
||||
insertStepIntoMeta,
|
||||
updateStepTitles
|
||||
} from './utils';
|
||||
|
||||
describe('Challenge utils helper scripts', () => {
|
||||
describe('createStepFile util', () => {
|
||||
@@ -57,6 +62,27 @@ describe('Challenge utils helper scripts', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('createChallengeFile util', () => {
|
||||
it('should create the challenge', () => {
|
||||
mock({
|
||||
'project/': {
|
||||
'fake-challenge.md': 'Lorem ipsum...',
|
||||
'so-many-fakes.md': 'Lorem ipsum...'
|
||||
}
|
||||
});
|
||||
|
||||
createChallengeFile('hi', 'pretend this is a template', 'project/');
|
||||
// - Should write a file with a given name and template
|
||||
const files = glob.sync(`project/*.md`);
|
||||
|
||||
expect(files).toEqual([
|
||||
`project/fake-challenge.md`,
|
||||
`project/hi.md`,
|
||||
`project/so-many-fakes.md`
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('insertStepIntoMeta util', () => {
|
||||
it('should update the meta with a new file id and name', () => {
|
||||
mock({
|
||||
|
||||
Reference in New Issue
Block a user