-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.spec.js
81 lines (73 loc) · 1.89 KB
/
App.spec.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React from "react"
import App, {toggleOneTodo} from "./App"
import {mount} from 'cypress-react-unit-test'
describe('App', () => {
beforeEach(() => {
mount(
<App />,
{
stylesheets: [
'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css'
]
}
)
})
it('works', () => {
cy.get('.todo').should('have.length', 3)
cy.get('input.input').type('Test with Cypress{enter}')
cy.get('.todo').should('have.length', 4)
.contains('Meet friend for lunch')
.find('[data-cy=remove]').click()
cy.get('.todo').should('have.length', 3)
})
it('toggles correctly', () => {
const todos = [{
isCompleted: false
}, {
isCompleted: false
}, {
isCompleted: false
}]
const newTodos = toggleOneTodo(todos, 2)
expect(newTodos).to.deep.equal([{
isCompleted: false
}, {
isCompleted: false
}, {
isCompleted: true
}])
})
it('ignores invalid index', () => {
const todos = [{
isCompleted: false
}, {
isCompleted: false
}, {
isCompleted: false
}]
const newTodos = toggleOneTodo(todos, 20)
expect(newTodos).to.deep.equal(todos)
})
it('toggles an item', () => {
cy.get('.todo').should('have.length', 3)
.contains('Learn about React')
.contains('button', 'Complete').click()
cy.contains('Learn about React')
.should('have.css', 'text-decoration',
'line-through solid rgb(74, 74, 74)')
.then(() => {
cy.wrap(window.todos[0]).should('deep.equal', {
text: 'Learn about React',
isCompleted: true
})
})
cy.contains('Learn about React')
.contains('button', 'Redo').click()
.then(() => {
cy.wrap(window.todos[0]).should('deep.equal', {
text: 'Learn about React',
isCompleted: false
})
})
})
})