Browse Source

the-calling: test and review

pull/748/head
Clement Denis 3 years ago committed by Clément
parent
commit
913c01184e
  1. 28
      dom/the-calling_test.js
  2. 31
      subjects/the-calling/README.md

28
dom/the-calling_test.js

@ -1,19 +1,19 @@
export const tests = [] export const tests = []
tests.push(async ({ page, eq }) => { tests.push(async ({ page, eq }) => {
// check the 3 sections have the correct id and no text // check the face
const elements = await page.$$eval('body', (nodes) =>
[...nodes[0].children].map((node) => ({ return eq.$('section#face', { textContent: '' })
tag: node.tagName.toLowerCase(), })
text: node.textContent,
id: node.id, tests.push(async ({ page, eq }) => {
})), // check the upper-body
)
eq(expectedSections, elements) return eq.$('section#upper-body', { textContent: '' })
}) })
const expectedSections = [ tests.push(async ({ page, eq }) => {
{ tag: 'section', text: '', id: 'face' }, // check the lower-body, my favorite part
{ tag: 'section', text: '', id: 'upper-body' },
{ tag: 'section', text: '', id: 'lower-body' }, return eq.$('section#lower-body', { textContent: '' })
] })

31
subjects/the-calling/README.md

@ -1,12 +1,31 @@
### The calling ## The calling
Congrats! You created the very first base for your being and you witnessed its appearance on the digital world - your browser. But so far, it's a tiny seed of the marvelous thing it could become ; be patient, there still is a bit of work. Congrats! You created the very first base for your being and you witnessed its
First of all, instead of writing down what things are - you're not writing down on your hand the word 'hand', are you?) - we're going to identify them semantically with the very practical [`id`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id) attribute. This `id` has to be a unique identifier in your webpage, which will allow you to target your element if needed. appearance on the digital world - your browser. But so far, it's a tiny seed of
Your can compare it to your name & surname ; this is what is identifying you to other people, and if someone's calling you by your name, you answer. the marvelous thing it could become ; be patient, there still is a bit of work.
So let's identify the 3 elements we have so far: in each section, remove the text content from inside the tag and set it as the value of the `id` attribute of the corresponding `section` tag. ### Instructions
Open the page in the browser: you don't see anything? Don't freak out! Inspect the HTML that have been created with your [browser inspector tool](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_are_browser_developer_tools), & if you worked well, you should see inside the `body` the 3 sections with the `id` attribute set in your HTML structure. First of all, instead of writing down what things are _(you're not writing down
on your hand the word 'hand', are you?)_ we're going to identify them
semantically with the very practical
[`id`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id)
attribute. \
This `id` has to be a **unique** identifier in your webpage, which will allow you
to target your element if needed. Your can compare it to your name & surname ; this
is what is identifying you to other people, and if someone's calling you by your
name, you answer.
So let's identify the 3 elements we have so far: in each section, remove the
text content from inside the tag and set it as the value of the `id` attribute
of the corresponding `section` text.
**Open the page in the browser:** \
you don't see _anything_? Don't freak out! \
Inspect the HTML that have been created with your
[browser inspector tool](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_are_browser_developer_tools),
& if you done it correctly, you should see inside the `body` the 3 sections with
the `id` attribute set in your HTML structure.
### Notions ### Notions

Loading…
Cancel
Save