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:
Naomi Carrigan
2023-07-11 10:32:25 -07:00
committed by GitHub
parent ac48d14f8d
commit a374c2fade
15 changed files with 734 additions and 17 deletions

View File

@@ -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({