forked from bahmutov/test-todomvc-using-app-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.page.js
61 lines (49 loc) · 1.34 KB
/
todo.page.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/// <reference types="cypress" />
export class TodoPage {
static TODO_ITEM_ONE = 'buy some cheese'
static TODO_ITEM_TWO = 'feed the cat'
static TODO_ITEM_THREE = 'book a doctors appointment'
visit () {
cy.visit('/')
}
createTodos () {
cy.get('.new-todo', { log: false })
.type(`${TodoPage.TODO_ITEM_ONE}{enter}`, { log: false })
.type(`${TodoPage.TODO_ITEM_TWO}{enter}`, { log: false })
.type(`${TodoPage.TODO_ITEM_THREE}{enter}`, { log: false })
cy.log('TodoPage: created todos')
cy.get('.todo-list li', { log: false }).as('todos')
}
createTodo (todo) {
cy.get('.new-todo', { log: false }).type(`${todo}{enter}`, { log: false })
cy.log(`Created todo "${todo}"`)
return cy
.get('.todo-list', { log: false })
.contains('li', todo.trim(), { log: false })
}
toggle (k) {
cy.get('.todo-list li', { log: false })
.eq(k)
.find('.toggle')
.check()
}
/**
* Returns either all todo items on the page,
* or just a given one (zero index)
*/
todos (k) {
if (k !== undefined) {
return cy.get('.todo-list li').eq(k)
}
return cy.get('.todo-list li')
}
filter (label) {
cy.get('.filters')
.contains(label)
.click()
}
clearCompleted () {
cy.get('.clear-completed').click()
}
}
export const todoPage = new TodoPage()