Browse Source

Refactored `keycodes symphony` test.

pull/603/head
Marie Malarme 4 years ago committed by Clément
parent
commit
b3563b6ed9
  1. 13
      puppeteer/keycodes-symphony_test.js

13
puppeteer/keycodes-symphony_test.js

@ -5,10 +5,6 @@ export const setup = async ({ page }) => ({
await page.$$eval('.note', (nodes) => { await page.$$eval('.note', (nodes) => {
return nodes.map((note) => note.textContent) return nodes.map((note) => note.textContent)
}), }),
getNotesBg: async () =>
await page.$$eval('.note', (nodes) => {
return nodes.map((note) => note.style.background)
}),
}) })
const characters = `did you handle the keydown event correctly ?` const characters = `did you handle the keydown event correctly ?`
@ -40,7 +36,7 @@ tests.push(async ({ page, eq, getNotes }) => {
eq(await cleared, true) eq(await cleared, true)
}) })
tests.push(async ({ page, eq, getNotesBg }) => { tests.push(async ({ page, eq }) => {
// check that notes have different background colors // check that notes have different background colors
const test = 'abcdefghijklmnopqrstuvwxyz' const test = 'abcdefghijklmnopqrstuvwxyz'
let step = 0 let step = 0
@ -48,7 +44,12 @@ tests.push(async ({ page, eq, getNotesBg }) => {
await page.keyboard.down(test[step]) await page.keyboard.down(test[step])
step++ step++
} }
const colors = [...new Set(await getNotesBg())]
const getNotesBg = await page.$$eval('.note', (nodes) => {
return nodes.map((note) => note.style.background)
})
const colors = [...new Set(getNotesBg)]
const allDifferent = colors.length === test.length const allDifferent = colors.length === test.length
eq(allDifferent, true) eq(allDifferent, true)
}) })

Loading…
Cancel
Save