Files
freeCodeCamp/tools/challenge-helper-scripts/helpers/get-last-step-file-content.test.js
Nicholas Carrigan (he/him) b36cdbafd1 chore: rename "part" to "step" (#43934)
* chore: rename part to step

* chore: update metas

* chore: more renaming

* chore: update tooling

* chore: update frontmatter

* chore(tools): title testing
2021-10-21 18:07:52 +01:00

58 lines
1.2 KiB
JavaScript

const mock = require('mock-fs');
const { getLastStepFileContent } = require('./get-last-step-file-content');
jest.mock('./get-project-path', () => {
return {
getProjectPath: jest.fn(() => 'mock-project/')
};
});
jest.mock('../utils', () => {
return {
getChallengeSeeds: jest.fn(() => {
return {
lorem: 'ipsum'
};
})
};
});
describe('getLastStepFileContent helper', () => {
it('should throw if last step count does not match with numbers of steps', () => {
mock({
'mock-project/': {
'step-001.md': 'Lorem ipsum...',
'step-004.md': 'Lorem ipsum...',
'final.md': 'Lorem ipsum...'
}
});
expect(() => {
getLastStepFileContent();
}).toThrow();
mock.restore();
});
it('should return information if steps count is correct', () => {
mock({
'mock-project': {
'step-001.md': 'Lorem ipsum...',
'step-002.md': 'Lorem ipsum...',
'final.md': 'Lorem ipsum...'
}
});
const expected = {
nextStepNum: 3,
challengeSeeds: {
lorem: 'ipsum'
}
};
expect(getLastStepFileContent()).toEqual(expected);
mock.restore();
});
});