From 29f43a9816db5d60f444e8a9df024ce4490cf8ed Mon Sep 17 00:00:00 2001 From: Marie Malarme Date: Tue, 2 Mar 2021 21:06:06 +0000 Subject: [PATCH] Test for action-reaction --- dom/action-reaction_test.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 dom/action-reaction_test.js diff --git a/dom/action-reaction_test.js b/dom/action-reaction_test.js new file mode 100644 index 00000000..182a1f86 --- /dev/null +++ b/dom/action-reaction_test.js @@ -0,0 +1,25 @@ +export const tests = [] + +tests.push(async ({ eq, page }) => { + // check the initial class name of the eye left + const eyeLeft = await page.$eval('#eye-left', (node) => node.className) + eq(eyeLeft, 'eye') +}) + +tests.push(async ({ eq, page }) => { + // click the button to close the left eye + const button = await page.$('button') + button.click() + await page.waitForTimeout(150) + const eyeLeft = await page.$eval('#eye-left', (node) => node.className) + eq(eyeLeft, 'eye eye-closed') +}) + +tests.push(async ({ eq, page }) => { + // click the button a second time to open the left eye + const button = await page.$('button') + button.click() + await page.waitForTimeout(150) + const eyeLeft = await page.$eval('#eye-left', (node) => node.className) + eq(eyeLeft, 'eye') +})