Skip to content

Commit

Permalink
tests(project): Add tests for variant and optional learning objectives
Browse files Browse the repository at this point in the history
  • Loading branch information
mfdebian committed Apr 2, 2024
1 parent 8387e2c commit 849b50c
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# A project

## Índice

Blah blah blah

***

## 1. Preámbulo

Blah blah blah

## 2. Resumen del proyecto

Blah blah blah
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# A project

## Índice

Blah blah blah

***

## 1. Preámbulo

Blah blah blah

## 2. Resumen del proyecto

Blah blah blah
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions lib/__tests__/__snapshots__/project.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,32 @@ poderá cifrar e decifrar um texto indicando a chave de deslocamento (<em>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",
]
`;
25 changes: 25 additions & 0 deletions lib/__tests__/project.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions lib/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 849b50c

Please sign in to comment.