diff --git a/lib/__tests__/__fixtures__/01-a-project-with-learning-objectives-variants/README.md b/lib/__tests__/__fixtures__/01-a-project-with-learning-objectives-variants/README.md new file mode 100644 index 0000000..841e5d5 --- /dev/null +++ b/lib/__tests__/__fixtures__/01-a-project-with-learning-objectives-variants/README.md @@ -0,0 +1,15 @@ +# A project + +## Índice + +Blah blah blah + +*** + +## 1. Preámbulo + +Blah blah blah + +## 2. Resumen del proyecto + +Blah blah blah diff --git a/lib/__tests__/__fixtures__/01-a-project-with-learning-objectives-variants/project.yml b/lib/__tests__/__fixtures__/01-a-project-with-learning-objectives-variants/project.yml new file mode 100644 index 0000000..553b267 --- /dev/null +++ b/lib/__tests__/__fixtures__/01-a-project-with-learning-objectives-variants/project.yml @@ -0,0 +1,21 @@ +track: web-dev +tracks: + - web-dev +learningObjectives: + - html/semantics + - css/selectors + - dom/selectors + - dom/events + - dom/manipulation + - js/data-types/primitive-vs-non-primitive + - js/data-types/strings + - js/variables + - js/conditionals + - js/functions + - js/semantics + - ux/user-understanding + - ux/prototyping +variants: + - name: node + learningObjectives: + - node diff --git a/lib/__tests__/__fixtures__/01-a-project-with-optional-learning-objectives/README.md b/lib/__tests__/__fixtures__/01-a-project-with-optional-learning-objectives/README.md new file mode 100644 index 0000000..841e5d5 --- /dev/null +++ b/lib/__tests__/__fixtures__/01-a-project-with-optional-learning-objectives/README.md @@ -0,0 +1,15 @@ +# A project + +## Índice + +Blah blah blah + +*** + +## 1. Preámbulo + +Blah blah blah + +## 2. Resumen del proyecto + +Blah blah blah diff --git a/lib/__tests__/__fixtures__/01-a-project-with-optional-learning-objectives/project.yml b/lib/__tests__/__fixtures__/01-a-project-with-optional-learning-objectives/project.yml new file mode 100644 index 0000000..a8b39ec --- /dev/null +++ b/lib/__tests__/__fixtures__/01-a-project-with-optional-learning-objectives/project.yml @@ -0,0 +1,19 @@ +track: web-dev +tracks: + - web-dev +learningObjectives: + - html/semantics + - css/selectors + - dom/selectors + - dom/events + - dom/manipulation + - js/data-types/primitive-vs-non-primitive + - js/data-types/strings + - js/variables + - js/conditionals + - js/functions + - js/semantics + - ux/user-understanding + - ux/prototyping + - object-oriented-programming: + optional: true diff --git a/lib/__tests__/__snapshots__/project.spec.js.snap b/lib/__tests__/__snapshots__/project.spec.js.snap index 3a25a32..93fc5c5 100644 --- a/lib/__tests__/__snapshots__/project.spec.js.snap +++ b/lib/__tests__/__snapshots__/project.spec.js.snap @@ -147,3 +147,32 @@ poderá cifrar e decifrar um texto indicando a chave de deslocamento (offset "version": "1.0.0", } `; + +exports[`parseProject > should include learning objectives from variant if a variant is passed 1`] = ` +[ + "html/semantics", + "css/selectors", + "dom/selectors", + "dom/events", + "dom/manipulation", + "js/data-types/primitive-vs-non-primitive", + "js/data-types/strings", + "js/variables/declaration", + "js/conditionals", + "js/functions", + "js/semantics", + "ux/user-understanding", + "ux/prototyping", + "node/npm-install", + "node/package.json", + "node/npm-scripts", + "node/process", + "node/filesystem", +] +`; + +exports[`parseProject > should include optional learning objectives if theyre present 1`] = ` +[ + "object-oriented-programming", +] +`; diff --git a/lib/__tests__/project.spec.js b/lib/__tests__/project.spec.js index 150149a..308f76d 100644 --- a/lib/__tests__/project.spec.js +++ b/lib/__tests__/project.spec.js @@ -159,6 +159,31 @@ describe('parseProject', () => { }); }); + it('should include learning objectives from variant if a variant is passed', () => { + const p = resolveFixturePath('01-a-project-with-learning-objectives-variants'); + return parseProject(p, { + repo: 'Laboratoria/bootcamp', + version: '1.0.0', + lo: path.join(__dirname, '__fixtures__', 'learning-objectives'), + variants: 'node', + }, pkg) + .then((result) => { + expect(result.learningObjectives).toMatchSnapshot(); + }); + }); + + it('should include optional learning objectives if theyre present', () => { + const p = resolveFixturePath('01-a-project-with-optional-learning-objectives'); + return parseProject(p, { + repo: 'Laboratoria/bootcamp', + version: '1.0.0', + lo: path.join(__dirname, '__fixtures__', 'learning-objectives'), + }, pkg) + .then((result) => { + expect(result.optionalLearningObjectives).toMatchSnapshot(); + }); + }); + it('extracts first paragraph of _resumen del proyecto_ as summary', () => { const p = resolveFixturePath('01-a-project-with-summary'); expect.assertions(2); diff --git a/lib/project.js b/lib/project.js index 09e63b5..08f1fe9 100644 --- a/lib/project.js +++ b/lib/project.js @@ -143,17 +143,15 @@ export const transformLearningObjectives = async (dir, opts, meta) => { if (learningObjective[Object.keys(learningObjective)[0]].optional && !optionalLearningObjectives.includes(Object.keys(learningObjective)[0])) { optionalLearningObjectives.push(Object.keys(learningObjective)[0]); - // console.log("learningobjective a sacar del array:", learningObjective); const index = learningObjectives.indexOf(learningObjective); - if (index > -1) { // only splice array when item is found - learningObjectives.splice(index, 1); // 2nd parameter means remove one item only + if (index > -1) { + learningObjectives.splice(index, 1); } } } }); variants?.forEach((variantInYml) => { - // console.log("HAY VARIAN3"); if (variantOptions.includes(variantInYml.name)) { variantInYml.learningObjectives.forEach((learningObjective) => { if (typeof learningObjective === 'string') {