Skip to content

Commit

Permalink
completed chapter 7; includes examples of assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
leobooth committed Jul 16, 2024
1 parent dc244e5 commit 7b49bd1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,26 @@ function addTodo(todoText) {
function removeTodo(todoText) {
let todoItem = cy.get("[data-testid='todo-item-label']").contains(todoText);
todoItem.trigger('mouseover');
let todoItemRemoveButton = cy.get("[data-testid='todo-item-button']");
let todoItemRemoveButton =
cy.get("[data-testid='todo-item-label']").contains(todoText)
.siblings("[data-testid='todo-item-button']");
todoItemRemoveButton.click({force: true});
}

it('add and remove a single todo item', () => {
it('add and remove a single todo item using todo item remove button', () => {
cy.visit('https://todomvc.com/examples/react/dist/');
addTodo('todo1');
let todo1 = cy.get("[data-testid='todo-item-label']").contains('todo1');
todo1.should('be.visible');
removeTodo('todo1');
});

it('should show two todo items', () => {
cy.visit('https://todomvc.com/examples/react/dist/');
addTodo('todo1');
addTodo('todo2');

cy.get("[data-testid='todo-item-label']").should('have.length', 2);
removeTodo('todo1');
removeTodo('todo2');
});

0 comments on commit 7b49bd1

Please sign in to comment.