|
|
|
@ -1,11 +1,12 @@
|
|
|
|
|
export const tests = [] |
|
|
|
|
|
|
|
|
|
export const setup = async ({ page }) => ({ |
|
|
|
|
getNotes: async () => |
|
|
|
|
export const setup = async () => { |
|
|
|
|
const getNotes = async (page) => |
|
|
|
|
await page.$$eval('.note', (nodes) => { |
|
|
|
|
return nodes.map((note) => note.textContent) |
|
|
|
|
}), |
|
|
|
|
}) |
|
|
|
|
return { getNotes } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const characters = `didyouhandlethekeydowneventcorrectly` |
|
|
|
|
|
|
|
|
@ -14,7 +15,7 @@ tests.push(async ({ page, eq, ctx }) => {
|
|
|
|
|
for (const [i, character] of characters.split('').entries()) { |
|
|
|
|
await page.keyboard.down(character) |
|
|
|
|
const typed = characters.slice(0, i + 1).split('') |
|
|
|
|
eq(await ctx.getNotes(), typed) |
|
|
|
|
eq(await ctx.getNotes(page), typed) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
@ -24,7 +25,7 @@ tests.push(async ({ page, eq, ctx }) => {
|
|
|
|
|
while (step < 10) { |
|
|
|
|
await page.keyboard.down('Backspace') |
|
|
|
|
const typed = characters.slice(0, characters.length - step).split('') |
|
|
|
|
eq(await ctx.getNotes(), typed) |
|
|
|
|
eq(await ctx.getNotes(page), typed) |
|
|
|
|
step++ |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -32,8 +33,8 @@ tests.push(async ({ page, eq, ctx }) => {
|
|
|
|
|
tests.push(async ({ page, eq, ctx }) => { |
|
|
|
|
// check that all the notes are cleared when Escape key is pressed
|
|
|
|
|
await page.keyboard.down('Escape') |
|
|
|
|
const cleared = (await ctx.getNotes()).length === 0 |
|
|
|
|
eq(await cleared, true) |
|
|
|
|
const cleared = (await ctx.getNotes(page)).length === 0 |
|
|
|
|
eq(cleared, true) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
tests.push(async ({ page, eq }) => { |
|
|
|
|