Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more semantic button selectors in test #280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Sprint-3/todo-list/script.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ describe("Mandatory tasks", () => {

listItems.forEach((_, index) => {
const tickIcon = page.window.document.querySelector(
`li:nth-child(${index + 1}) i.fa-check`
`li:nth-child(${index + 1}) .done-button`
);
const binIcon = page.window.document.querySelector(
`li:nth-child(${index + 1}) i.fa-trash`
`li:nth-child(${index + 1}) .delete-button`
);

expect(tickIcon).toBeInTheDocument();
Expand All @@ -72,7 +72,7 @@ describe("Mandatory tasks", () => {

test("can strike through a todo when it is completed", () => {
const li = page.window.document.querySelector("li");
const tickIcon = page.window.document.querySelector("li i");
const tickIcon = page.window.document.querySelector("li .done-button");

userEvent.click(tickIcon);

Expand All @@ -83,7 +83,7 @@ describe("Mandatory tasks", () => {

test("can undo a strikethrough on a todo", () => {
const li = page.window.document.querySelector("li");
const tickIcon = page.window.document.querySelector("li i");
const tickIcon = page.window.document.querySelector("li .done-button");
userEvent.click(tickIcon);

expect(li).toHaveStyle({
Expand Down Expand Up @@ -111,7 +111,7 @@ describe("Mandatory tasks", () => {
expect(listItems.length).toBe(3);

const binIcon = page.window.document.querySelector(
"li:nth-child(3) i.fa-trash"
"li:nth-child(3) .delete-button"
);
userEvent.click(binIcon);

Expand All @@ -137,11 +137,11 @@ describe("Advanced tasks", () => {
userEvent.click(button);

const tickIcon2 = page.window.document.querySelector(
"li:nth-child(2) i.fa-check"
"li:nth-child(2) .done-button"
);
userEvent.click(tickIcon2);
const tickIcon4 = page.window.document.querySelector(
"li:nth-child(4) i.fa-check"
"li:nth-child(4) .done-button"
);
userEvent.click(tickIcon4);

Expand Down