(exercisePath)
| 3 | const { splitDirectoryName } = require("./helpers"); |
| 4 | |
| 5 | async function writeExerciseSpec(exercisePath) { |
| 6 | const { exerciseName } = splitDirectoryName(exercisePath); |
| 7 | const isSolutionFile = exercisePath.includes("/solution"); |
| 8 | const trueExerciseName = isSolutionFile |
| 9 | ? `${exerciseName}-solution` |
| 10 | : exerciseName; |
| 11 | |
| 12 | const exerciseSpecContent = `const ${exerciseName} = require('./${trueExerciseName}'); |
| 13 | |
| 14 | describe('${exerciseName}', () => { |
| 15 | test('First test description', () => { |
| 16 | // Replace this comment with any other necessary code, and update the expect line as necessary |
| 17 | |
| 18 | expect(${exerciseName}()).toBe(''); |
| 19 | }); |
| 20 | |
| 21 | test${isSolutionFile ? "" : ".skip"}('Second test description', () => { |
| 22 | // Replace this comment with any other necessary code, and update the expect line as necessary |
| 23 | |
| 24 | expect(${exerciseName}()).toBe(''); |
| 25 | }); |
| 26 | }); |
| 27 | `; |
| 28 | |
| 29 | await writeFile( |
| 30 | join(exercisePath, `${trueExerciseName}.spec.js`), |
| 31 | exerciseSpecContent |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | module.exports = { writeExerciseSpec }; |
no test coverage detected