mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore(curriculum): remove before/after user code (batch 03) (#66497)
This commit is contained in:
@@ -25,6 +25,12 @@ The `TypesOfFood` component should return a single `div` element.
|
||||
```js
|
||||
assert(
|
||||
(function () {
|
||||
globalThis.Fruits = function Fruits() {
|
||||
return React.createElement('div', null);
|
||||
};
|
||||
globalThis.Vegetables = function Vegetables() {
|
||||
return React.createElement('div', null);
|
||||
};
|
||||
const mockedComponent = Enzyme.mount(React.createElement(TypesOfFood));
|
||||
return mockedComponent.children().type() === 'div';
|
||||
})()
|
||||
@@ -36,6 +42,12 @@ The `TypesOfFood` component should render the `Fruits` component after the `h1`
|
||||
```js
|
||||
assert(
|
||||
(function () {
|
||||
globalThis.Fruits = function Fruits() {
|
||||
return React.createElement('div', null);
|
||||
};
|
||||
globalThis.Vegetables = function Vegetables() {
|
||||
return React.createElement('div', null);
|
||||
};
|
||||
const mockedComponent = Enzyme.mount(React.createElement(TypesOfFood));
|
||||
return mockedComponent.children().childAt(1).name() === 'Fruits';
|
||||
})()
|
||||
@@ -47,6 +59,12 @@ The `TypesOfFood` component should render the `Vegetables` component after `Frui
|
||||
```js
|
||||
assert(
|
||||
(function () {
|
||||
globalThis.Fruits = function Fruits() {
|
||||
return React.createElement('div', null);
|
||||
};
|
||||
globalThis.Vegetables = function Vegetables() {
|
||||
return React.createElement('div', null);
|
||||
};
|
||||
const mockedComponent = Enzyme.mount(React.createElement(TypesOfFood));
|
||||
return mockedComponent.children().childAt(2).name() === 'Vegetables';
|
||||
})()
|
||||
@@ -58,8 +76,64 @@ The `TypesOfFood` component should render to the DOM within the `div` with the i
|
||||
```js
|
||||
assert(
|
||||
(function () {
|
||||
const html = document.getElementById('challenge-node').childNodes[0]
|
||||
.innerHTML;
|
||||
const hasRenderCall = /ReactDOM\.render\(<TypesOfFood\/>,document\.getElementById\((['"`])challenge-node\1\)\);?/.test(
|
||||
__helpers.removeWhiteSpace(code)
|
||||
);
|
||||
if (!hasRenderCall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const e = React.createElement;
|
||||
globalThis.Fruits = function Fruits() {
|
||||
return e(
|
||||
'div',
|
||||
null,
|
||||
e('h2', null, 'Fruits:'),
|
||||
e('h4', null, 'Non-Citrus:'),
|
||||
e(
|
||||
'ul',
|
||||
null,
|
||||
e('li', null, 'Apples'),
|
||||
e('li', null, 'Blueberries'),
|
||||
e('li', null, 'Strawberries'),
|
||||
e('li', null, 'Bananas')
|
||||
),
|
||||
e('h4', null, 'Citrus:'),
|
||||
e(
|
||||
'ul',
|
||||
null,
|
||||
e('li', null, 'Lemon'),
|
||||
e('li', null, 'Lime'),
|
||||
e('li', null, 'Orange'),
|
||||
e('li', null, 'Grapefruit')
|
||||
)
|
||||
);
|
||||
};
|
||||
globalThis.Vegetables = function Vegetables() {
|
||||
return e(
|
||||
'div',
|
||||
null,
|
||||
e('h2', null, 'Vegetables:'),
|
||||
e(
|
||||
'ul',
|
||||
null,
|
||||
e('li', null, 'Brussel Sprouts'),
|
||||
e('li', null, 'Broccoli'),
|
||||
e('li', null, 'Squash')
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
ReactDOM.render(
|
||||
React.createElement(TypesOfFood),
|
||||
document.getElementById('challenge-node')
|
||||
);
|
||||
|
||||
const root = document.getElementById('challenge-node').childNodes[0];
|
||||
if (!root) {
|
||||
return false;
|
||||
}
|
||||
const html = root.innerHTML;
|
||||
return (
|
||||
html.includes(
|
||||
'<div><h2>Fruits:</h2><h4>Non-Citrus:</h4><ul><li>Apples</li><li>Blueberries</li><li>Strawberries</li><li>Bananas</li></ul><h4>Citrus:</h4><ul><li>Lemon</li><li>Lime</li><li>Orange</li><li>Grapefruit</li></ul></div>'
|
||||
@@ -74,44 +148,6 @@ assert(
|
||||
|
||||
# --seed--
|
||||
|
||||
## --before-user-code--
|
||||
|
||||
```jsx
|
||||
const Fruits = () => {
|
||||
return (
|
||||
<div>
|
||||
<h2>Fruits:</h2>
|
||||
<h4>Non-Citrus:</h4>
|
||||
<ul>
|
||||
<li>Apples</li>
|
||||
<li>Blueberries</li>
|
||||
<li>Strawberries</li>
|
||||
<li>Bananas</li>
|
||||
</ul>
|
||||
<h4>Citrus:</h4>
|
||||
<ul>
|
||||
<li>Lemon</li>
|
||||
<li>Lime</li>
|
||||
<li>Orange</li>
|
||||
<li>Grapefruit</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
const Vegetables = () => {
|
||||
return (
|
||||
<div>
|
||||
<h2>Vegetables:</h2>
|
||||
<ul>
|
||||
<li>Brussel Sprouts</li>
|
||||
<li>Broccoli</li>
|
||||
<li>Squash</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```jsx
|
||||
|
||||
@@ -97,12 +97,6 @@ assert(
|
||||
|
||||
# --seed--
|
||||
|
||||
## --after-user-code--
|
||||
|
||||
```jsx
|
||||
ReactDOM.render(<Calendar />, document.getElementById('root'))
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```jsx
|
||||
|
||||
@@ -131,12 +131,6 @@ assert(
|
||||
|
||||
# --seed--
|
||||
|
||||
## --after-user-code--
|
||||
|
||||
```jsx
|
||||
ReactDOM.render(<ToDo />, document.getElementById('root'))
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```jsx
|
||||
|
||||
@@ -41,12 +41,6 @@ assert(
|
||||
|
||||
# --seed--
|
||||
|
||||
## --after-user-code--
|
||||
|
||||
```jsx
|
||||
ReactDOM.render(<ShoppingCart />, document.getElementById('root'))
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```jsx
|
||||
|
||||
@@ -57,12 +57,6 @@ assert(
|
||||
|
||||
# --seed--
|
||||
|
||||
## --after-user-code--
|
||||
|
||||
```jsx
|
||||
ReactDOM.render(<ShoppingCart />, document.getElementById('root'))
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```jsx
|
||||
|
||||
Reference in New Issue
Block a user