mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 18:18:27 -05:00
fix(curriculum): test both stories in Sentence Maker (#57704)
Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com>
This commit is contained in:
@@ -119,11 +119,18 @@ You should declare a `firstStory` variable.
|
||||
assert.isNotNull(firstStory);
|
||||
```
|
||||
|
||||
Your should use the correct story format for both stories: `"Once upon a time, there was a(n) [adjective] [noun] who loved to eat [noun2]. The [noun] lived in a [place] and had [adjective2] nostrils that blew fire when it was [verb]."`. Pay attention to spaces.
|
||||
You should use the correct story format for the first story: `"Once upon a time, there was a(n) [adjective] [noun] who loved to eat [noun2]. The [noun] lived in a [place] and had [adjective2] nostrils that blew fire when it was [verb]."`. Pay attention to spaces.
|
||||
|
||||
```js
|
||||
const expected = `Once upon a time, there was a(n) ${adjective} ${noun} who loved to eat ${noun2}. The ${noun} lived in a ${place} and had ${adjective2} nostrils that blew fire when it was ${verb}.`;
|
||||
assert.strictEqual(secondStory, expected);
|
||||
const _initialValues = {}
|
||||
for (const name of ['adjective', 'noun', 'noun2', 'place', 'verb', 'adjective2']) {
|
||||
const match = code.match(new RegExp(String.raw`${name}\s*=\s*('|"|${'`'})(?<${name}>.*)\1;?\s*`));
|
||||
_initialValues[name] = match ? match.groups[name] : null;
|
||||
}
|
||||
|
||||
const expected = `Once upon a time, there was a(n) ${_initialValues['adjective']} ${_initialValues['noun']} who loved to eat ${_initialValues['noun2']}. The ${_initialValues['noun']} lived in a ${_initialValues['place']} and had ${_initialValues['adjective2']} nostrils that blew fire when it was ${_initialValues['verb']}.`;
|
||||
|
||||
assert.strictEqual(firstStory, expected);
|
||||
```
|
||||
|
||||
You should log your first story using the message `"First story: [firstStory]"`.
|
||||
@@ -176,6 +183,13 @@ You should reassign the `noun2` variable for the second story.
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/noun2\s*=\s*/g), 2);
|
||||
```
|
||||
|
||||
You should use the correct story format for the second story: `"Once upon a time, there was a(n) [adjective] [noun] who loved to eat [noun2]. The [noun] lived in a [place] and had [adjective2] nostrils that blew fire when it was [verb]."`. Pay attention to spaces.
|
||||
|
||||
```js
|
||||
const expected = `Once upon a time, there was a(n) ${adjective} ${noun} who loved to eat ${noun2}. The ${noun} lived in a ${place} and had ${adjective2} nostrils that blew fire when it was ${verb}.`;
|
||||
assert.strictEqual(secondStory, expected);
|
||||
```
|
||||
|
||||
You should log your second story using the format `"Second story: [secondStory]"`.
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user