Skip to content

Commit

Permalink
Improved readability
Browse files Browse the repository at this point in the history
  • Loading branch information
verlok committed Apr 2, 2024
1 parent bcd8d6a commit 31b6610
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/e2e/background_image.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,21 @@ for (const { url, description } of pagesWithSimpleImages) {
const element = lazyElements.nth(i);
await element.scrollIntoViewIfNeeded();

// Check the src attribute
const expectedBg = await element.getAttribute("data-bg");
const expectedHiDpiBg = await element.getAttribute("data-bg-hidpi");
// Set expectations
const expectedBg = `background-image: url("${await element.getAttribute("data-bg")}");`;
const expectedHiDpiBg = `background-image: url("${await element.getAttribute(
"data-bg-hidpi"
)}");`;

if (!expectedHiDpiBg) {
await expect(element).toHaveAttribute("style", `background-image: url("${expectedBg}");`);
await expect(element).toHaveAttribute("style", expectedBg);
continue;
}

if (devicePixelRatio === 1) {
await expect(element).toHaveAttribute("style", `background-image: url("${expectedBg}");`);
if (devicePixelRatio > 1) {
await expect(element).toHaveAttribute("style", expectedHiDpiBg);
} else {
await expect(element).toHaveAttribute(
"style",
`background-image: url("${expectedHiDpiBg}");`
);
await expect(element).toHaveAttribute("style", expectedBg);
}
}
});
Expand Down

0 comments on commit 31b6610

Please sign in to comment.