diff --git a/lib/__tests__/__fixtures__/challenge-form-with-multiline-question/README.md b/lib/__tests__/__fixtures__/challenge-form-with-multiline-question/README.md new file mode 100644 index 0000000..2b2afa6 --- /dev/null +++ b/lib/__tests__/__fixtures__/challenge-form-with-multiline-question/README.md @@ -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 diff --git a/lib/__tests__/__fixtures__/challenge-form-with-multiline-question/challenge.yml b/lib/__tests__/__fixtures__/challenge-form-with-multiline-question/challenge.yml new file mode 100644 index 0000000..d0436a3 --- /dev/null +++ b/lib/__tests__/__fixtures__/challenge-form-with-multiline-question/challenge.yml @@ -0,0 +1,2 @@ +track: ux +env: form diff --git a/lib/__tests__/__snapshots__/challenge.spec.js.snap b/lib/__tests__/__snapshots__/challenge.spec.js.snap index 52b0498..b32d194 100644 --- a/lib/__tests__/__snapshots__/challenge.spec.js.snap +++ b/lib/__tests__/__snapshots__/challenge.spec.js.snap @@ -80,3 +80,16 @@ exports[`parseChallenge > parses form challenge 1`] = ` }, ] `; + +exports[`parseChallenge > parses form challenge with multiline question 1`] = ` +[ + { + "body": "
Texto complementarion de la pregunta.
", + "solution": { + "multiline": true, + "required": true, + }, + "title": "What is the meaning of the universe?", + }, +] +`; diff --git a/lib/__tests__/challenge.spec.js b/lib/__tests__/challenge.spec.js index a1443d8..dd4e99b 100644 --- a/lib/__tests__/challenge.spec.js +++ b/lib/__tests__/challenge.spec.js @@ -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); }); }); diff --git a/lib/challenge.js b/lib/challenge.js index c7a705c..ad99047 100644 --- a/lib/challenge.js +++ b/lib/challenge.js @@ -144,7 +144,7 @@ const parseForm = async (children) => { return { ...prev, [name]: ( - name === 'required' + ['required', 'multiline'].includes(name) ? value !== 'false' : value ),