From a2a804c5eb1a3bc87d7aa185bc99e730c30b4d02 Mon Sep 17 00:00:00 2001 From: Marie Malarme Date: Tue, 2 Mar 2021 17:40:25 +0000 Subject: [PATCH] Test for skeleton --- dom/skeleton_test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 dom/skeleton_test.js diff --git a/dom/skeleton_test.js b/dom/skeleton_test.js new file mode 100644 index 00000000..d588e96c --- /dev/null +++ b/dom/skeleton_test.js @@ -0,0 +1,26 @@ +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) + + // check the 3 sections have been created with the correct text + const sections = await page.$$eval('section', (nodes) => + nodes.map((node) => ({ + tag: node.tagName.toLowerCase(), + text: node.textContent, + })), + ) + eq(expectedSections, sections) +}) + +const expectedSections = [ + { tag: 'section', text: 'face' }, + { tag: 'section', text: 'upper-body' }, + { tag: 'section', text: 'lower-body' }, +]