From 490c003b647ae8b2c7849c6ee4fedc0987d10c25 Mon Sep 17 00:00:00 2001 From: Sem Bauke Date: Tue, 17 Mar 2026 10:58:50 +0100 Subject: [PATCH] chore(curriculum): remove before/after user code (batch 03) (#66497) --- .../blocks/react/5a24c314108439a4d4036167.md | 116 ++++++++++++------ .../blocks/react/5a24c314108439a4d4036169.md | 6 - .../blocks/react/5a24c314108439a4d403616a.md | 6 - .../blocks/react/5a24c314108439a4d403616b.md | 6 - .../blocks/react/5a24c314108439a4d403616c.md | 6 - 5 files changed, 76 insertions(+), 64 deletions(-) diff --git a/curriculum/challenges/english/blocks/react/5a24c314108439a4d4036167.md b/curriculum/challenges/english/blocks/react/5a24c314108439a4d4036167.md index 2e3a9a7a562..49459a2d318 100644 --- a/curriculum/challenges/english/blocks/react/5a24c314108439a4d4036167.md +++ b/curriculum/challenges/english/blocks/react/5a24c314108439a4d4036167.md @@ -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\(,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( '

Fruits:

Non-Citrus:

  • Apples
  • Blueberries
  • Strawberries
  • Bananas

Citrus:

  • Lemon
  • Lime
  • Orange
  • Grapefruit
' @@ -74,44 +148,6 @@ assert( # --seed-- -## --before-user-code-- - -```jsx -const Fruits = () => { - return ( -
-

Fruits:

-

Non-Citrus:

-
    -
  • Apples
  • -
  • Blueberries
  • -
  • Strawberries
  • -
  • Bananas
  • -
-

Citrus:

-
    -
  • Lemon
  • -
  • Lime
  • -
  • Orange
  • -
  • Grapefruit
  • -
-
- ); -}; -const Vegetables = () => { - return ( -
-

Vegetables:

-
    -
  • Brussel Sprouts
  • -
  • Broccoli
  • -
  • Squash
  • -
-
- ); -}; -``` - ## --seed-contents-- ```jsx diff --git a/curriculum/challenges/english/blocks/react/5a24c314108439a4d4036169.md b/curriculum/challenges/english/blocks/react/5a24c314108439a4d4036169.md index b8f61177082..e7710421735 100644 --- a/curriculum/challenges/english/blocks/react/5a24c314108439a4d4036169.md +++ b/curriculum/challenges/english/blocks/react/5a24c314108439a4d4036169.md @@ -97,12 +97,6 @@ assert( # --seed-- -## --after-user-code-- - -```jsx -ReactDOM.render(, document.getElementById('root')) -``` - ## --seed-contents-- ```jsx diff --git a/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616a.md b/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616a.md index f9c089485a2..82d8cec979e 100644 --- a/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616a.md +++ b/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616a.md @@ -131,12 +131,6 @@ assert( # --seed-- -## --after-user-code-- - -```jsx -ReactDOM.render(, document.getElementById('root')) -``` - ## --seed-contents-- ```jsx diff --git a/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616b.md b/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616b.md index 1f048ada95f..b1c41079cb7 100644 --- a/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616b.md +++ b/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616b.md @@ -41,12 +41,6 @@ assert( # --seed-- -## --after-user-code-- - -```jsx -ReactDOM.render(, document.getElementById('root')) -``` - ## --seed-contents-- ```jsx diff --git a/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616c.md b/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616c.md index 7aa0cdce032..33990c3b26b 100644 --- a/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616c.md +++ b/curriculum/challenges/english/blocks/react/5a24c314108439a4d403616c.md @@ -57,12 +57,6 @@ assert( # --seed-- -## --after-user-code-- - -```jsx -ReactDOM.render(, document.getElementById('root')) -``` - ## --seed-contents-- ```jsx