public/dom/skeleton_test.js

29 lines
791 B
JavaScript
Raw Normal View History

2021-03-02 17:40:25 +00:00
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)
2021-03-02 20:45:57 +00:00
})
2021-03-02 17:40:25 +00:00
2021-03-02 20:45:57 +00:00
tests.push(async ({ page, eq }) => {
2021-03-02 17:40:25 +00:00
// check the 3 sections have been created with the correct text
const elements = await page.$$eval('body', (nodes) =>
[...nodes[0].children].map((node) => ({
2021-03-02 17:40:25 +00:00
tag: node.tagName.toLowerCase(),
text: node.textContent,
})),
)
eq(expectedSections, elements)
2021-03-02 17:40:25 +00:00
})
const expectedSections = [
{ tag: 'section', text: 'face' },
{ tag: 'section', text: 'upper-body' },
{ tag: 'section', text: 'lower-body' },
]