forked from cypress-io/cypress-react-unit-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounter-spec.js
47 lines (42 loc) · 940 Bytes
/
counter-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
import { Counter } from '../../src/counter.jsx'
import React from 'react'
import { mount } from '../../lib'
/* eslint-env mocha */
describe('Counter', () => {
it('counts clicks', () => {
mount(<Counter />)
cy.contains('count: 0')
.click()
.contains('count: 1')
.click()
.contains('count: 2')
})
it('counts clicks 2', () => {
mount(<Counter />)
cy.contains('count: 0')
.click()
.contains('count: 1')
.click()
.contains('count: 2')
})
})
describe('Counter mounted before each test', () => {
beforeEach(() => {
mount(<Counter />)
})
it('goes to 3', () => {
cy.contains('count: 0')
.click()
.click()
.click()
.contains('count: 3')
})
it('has count in state', () => {
cy.contains('count: 0')
.click()
.click()
.click()
Cypress.component().its('state')
.should('deep.equal', {count: 3})
})
})