Skip to content

Commit

Permalink
Tests(DPxAI): update test for class-it
Browse files Browse the repository at this point in the history
  • Loading branch information
lotoussa authored Nov 4, 2024
1 parent 23aec41 commit 050a618
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions dom/class-it_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ tests.push(async ({ page, eq }) => {
})

tests.push(async ({ page, eq }) => {
// check that the targetted elements have the correct class names
await eq.$('p#eye-left', { className: 'eye' })
await eq.$('p#eye-right', { className: 'eye' })
await eq.$('div#arm-left', { className: 'arm body-member' })
await eq.$('div#arm-right', { className: 'arm body-member' })
await eq.$('div#leg-left', { className: 'leg body-member' })
await eq.$('div#leg-right', { className: 'leg body-member' })
})
// Helper function to check if an element has the expected classes
async function hasClasses(selector, expectedClasses) {
const element = await page.$(selector);
const className = await element.evaluate(el => el.className);
const classList = className.split(' ').sort();
const expectedClassList = expectedClasses.split(' ').sort();
return JSON.stringify(classList) === JSON.stringify(expectedClassList);
}

// Check that the target elements have the correct classes
eq(await hasClasses('p#eye-left', 'eye'), true);
eq(await hasClasses('p#eye-right', 'eye'), true);
eq(await hasClasses('div#arm-left', 'arm body-member'), true);
eq(await hasClasses('div#arm-right', 'arm body-member'), true);
eq(await hasClasses('div#leg-left', 'leg body-member'), true);
eq(await hasClasses('div#leg-right', 'leg body-member'), true);
});

0 comments on commit 050a618

Please sign in to comment.