Skip to content

Commit

Permalink
feat(tests): Adds cases for '.pt' READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
mfdebian authored and lupomontero committed Oct 25, 2023
1 parent a07b600 commit e4bfb5a
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.

## Perguntas

#### What is the meaning of the universe?

Texto complementarion de la pregunta.

#### Solução

* `multiline`: true

### A question
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.

## Perguntas

### What is the meaning of the universe?

Texto complementarion de la pregunta.

#### Solução

* `multiline`: true
82 changes: 82 additions & 0 deletions lib/__tests__/__fixtures__/challenge-form/README.pt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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.

## Perguntas

### What is the meaning of the universe?

Texto complementarion de la pregunta.

#### Solução

* `value`: 42

### A question with multiple choices

#### Opções

1. A
2. B
3. C

#### Solução

* `value`: 2

### An optional question with multiple choices

#### Opções

1. A
2. B
3. C

#### Solução

* `value`: 2
* `required`: false

### Cuáles de las siguientes crees que son correctas?

#### Opções

1. aaa
2. bbb
3. ccc

#### Solução

* `value`: 1,2

### Anything else to say?

¿Alguna cosa más que agregar?

#### Solução

* `required`: false

### A required question without validation

#### Solução

* `required`: true

### A question with custom validation

#### Solução

* `validate`:
```js
(value) => {
if (!value.startWith('https://blah.blah/')) {
return 'Respuesta debe comenzr con https://blah.blah/';
}
}
```
103 changes: 103 additions & 0 deletions lib/__tests__/__snapshots__/challenge.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ exports[`parseChallenge > ignores questions with no heading 1`] = `
]
`;

exports[`parseChallenge > ignores questions with no heading 2`] = `
[
{
"body": "",
"title": "A question",
},
]
`;

exports[`parseChallenge > parses form challenge 1`] = `
[
{
Expand Down Expand Up @@ -90,6 +99,87 @@ exports[`parseChallenge > parses form challenge 1`] = `
]
`;

exports[`parseChallenge > parses form challenge 2`] = `
[
{
"body": "<p>Texto complementarion de la pregunta.</p>",
"solution": {
"required": true,
"value": "42",
},
"title": "What is the meaning of the universe?",
},
{
"body": "",
"options": [
"<p>A</p>",
"<p>B</p>",
"<p>C</p>",
],
"solution": {
"required": true,
"value": 1,
},
"title": "A question with multiple choices",
},
{
"body": "",
"options": [
"<p>A</p>",
"<p>B</p>",
"<p>C</p>",
],
"solution": {
"required": false,
"value": 1,
},
"title": "An optional question with multiple choices",
},
{
"body": "",
"options": [
"<p>aaa</p>",
"<p>bbb</p>",
"<p>ccc</p>",
],
"solution": {
"required": true,
"value": [
0,
1,
],
},
"title": "Cuáles de las siguientes crees que son correctas?",
},
{
"body": "<p>¿Alguna cosa más que agregar?</p>",
"solution": {
"required": false,
},
"title": "Anything else to say?",
},
{
"body": "",
"solution": {
"required": true,
},
"title": "A required question without validation",
},
{
"body": "",
"solution": {
"required": true,
"validate": "(value) => {
if (!value.startWith('https://blah.blah/')) {
return 'Respuesta debe comenzr con https://blah.blah/';
}
}",
},
"title": "A question with custom validation",
},
]
`;

exports[`parseChallenge > parses form challenge with multiline question 1`] = `
[
{
Expand All @@ -102,3 +192,16 @@ exports[`parseChallenge > parses form challenge with multiline question 1`] = `
},
]
`;

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

it('ignores questions with no heading', async () => {
const dir = resolveFixturePath('challenge-form-question-no-heading');
const parsed = await parseChallenge(dir, {}, {});
expect(parsed.env).toBe('form');
expect(parsed.intl.es.questions).toMatchSnapshot();
expect(parsed.intl.pt.questions).toMatchSnapshot();
});
});

0 comments on commit e4bfb5a

Please sign in to comment.