Skip to content

Commit

Permalink
feat(challenge): Agrega soporte para string multilinea en challenges …
Browse files Browse the repository at this point in the history
…del tipo Form
  • Loading branch information
mfdebian authored and lupomontero committed Aug 31, 2023
1 parent 899e801 commit 177bdbf
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Challenge tipo form de prueba

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

## Preguntas

### What is the meaning of the universe?

Texto complementarion de la pregunta.

#### Solución

* `multiline`: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
track: ux
env: form
13 changes: 13 additions & 0 deletions lib/__tests__/__snapshots__/challenge.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,16 @@ exports[`parseChallenge > parses form challenge 1`] = `
},
]
`;

exports[`parseChallenge > parses form challenge with multiline question 1`] = `
[
{
"body": "<p>Texto complementarion de la pregunta.</p>",
"solution": {
"multiline": true,
"required": true,
},
"title": "What is the meaning of the universe?",
},
]
`;
9 changes: 9 additions & 0 deletions lib/__tests__/challenge.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,14 @@ describe('parseChallenge', () => {
expect(parsed.env).toBe('form');
expect(parsed.track).toBe('data');
expect(parsed.intl.es.questions).toMatchSnapshot();
expect(parsed.intl.es.questions[0].solution.multiline).toBeFalsy();
});

it('parses form challenge with multiline question', async () => {
const dir = resolveFixturePath('challenge-form-with-multiline-question');
const parsed = await parseChallenge(dir, {}, {});
expect(parsed.env).toBe('form');
expect(parsed.intl.es.questions).toMatchSnapshot();
expect(parsed.intl.es.questions[0].solution.multiline).toBe(true);
});
});
2 changes: 1 addition & 1 deletion lib/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const parseForm = async (children) => {
return {
...prev,
[name]: (
name === 'required'
['required', 'multiline'].includes(name)
? value !== 'false'
: value
),
Expand Down

0 comments on commit 177bdbf

Please sign in to comment.