From d759f3de48eec887eef2766165ec7e87ebd361ea Mon Sep 17 00:00:00 2001 From: Clement Denis Date: Tue, 2 Mar 2021 21:26:57 +0000 Subject: [PATCH] skeleton: test and review --- dom/skeleton_test.js | 35 ++++++++++++++++------------------- subjects/skeleton/README.md | 4 ++-- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/dom/skeleton_test.js b/dom/skeleton_test.js index b0f6be75..832ee039 100644 --- a/dom/skeleton_test.js +++ b/dom/skeleton_test.js @@ -2,27 +2,24 @@ export const tests = [] tests.push(async ({ page, eq }) => { // check that the title tag is present & is set with some text - const title = await page.$$eval( - 'title', - (nodes) => nodes[0] && nodes[0].innerHTML, - ) - const isValidTitle = title !== undefined && title.length !== 0 - eq(isValidTitle, true) + const title = await page.$eval('title', (node) => node.textContent) + if (!title.length) throw Error('missing title') }) tests.push(async ({ page, eq }) => { - // check the 3 sections have been created with the correct text - const elements = await page.$$eval('body', (nodes) => - [...nodes[0].children].map((node) => ({ - tag: node.tagName.toLowerCase(), - text: node.textContent, - })), - ) - eq(expectedSections, elements) + // check the face + + return eq.$('section:nth-child(1)', { textContent: 'face' }) +}) + +tests.push(async ({ page, eq }) => { + // check the upper-body + + return eq.$('section:nth-child(2)', { textContent: 'upper-body' }) }) -const expectedSections = [ - { tag: 'section', text: 'face' }, - { tag: 'section', text: 'upper-body' }, - { tag: 'section', text: 'lower-body' }, -] +tests.push(async ({ page, eq }) => { + // check the lower-body, my favorite part + + return eq.$('section:nth-child(3)', { textContent: 'lower-body' }) +}) diff --git a/subjects/skeleton/README.md b/subjects/skeleton/README.md index 7a288851..6dd46273 100644 --- a/subjects/skeleton/README.md +++ b/subjects/skeleton/README.md @@ -7,7 +7,7 @@ In this new digital world you're gonna discover, it is possible to create beings Like a modern Dr Frankenstein, you're about to dive into the `world-wide-what` and give birth to a new entity on the virtual space of your browser. During this quest, step by step, you are going to shape it. -But before coding anything, make sure you checked the 2 videos of the playlist ; you need to have a server running on your computer. +But before coding anything, make sure you checked the videos of the playlist; you need to have a server running on your computer. For the whole quest, the principle is to iterate over your code: when you finish an exercise, copy-paste your code to use it in the next one. Naming of the files: @@ -35,7 +35,7 @@ Remember this as a general rule for any further project you will start: a good w Let's define the first level of elements that your entity will be made of ; we're going to split it into 3 main chunks: the face, the upper body, and the lower body. -Inside the `` tag of your HTML file, create 3 divisions using `
` tags, putting the following text content inside for each: 'face', 'upper-body', 'lower-body'. +Inside the `` tag of your HTML file, create 3 divisions using `
` tags, putting the following text content inside for each: `face`, `upper-body`, `lower-body`. If you open you HTML file in the browser, you should see those 3 texts appear on the screen.