forked from cypress-io/testing-workshop-cypress
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanswer.js
36 lines (31 loc) · 818 Bytes
/
answer.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
/// <reference types="cypress" />
import React from 'react'
import Footer from './Footer'
// adds custom command "cy.mount"
import 'cypress-react-unit-test'
import { filters } from './filters'
beforeEach(() => {
cy.viewport(500, 300)
})
it('shows Footer', () => {
cy.mount(<Footer count={10} nowShowing={filters.ALL_TODOS} />)
cy.get('footer')
.should('be.visible')
.find('[data-cy=show-all]')
.should('have.class', 'selected')
})
it('clears completed on click', () => {
cy.mount(
<Footer
count={10}
completedCount={4}
nowShowing={filters.ALL_TODOS}
onClearCompleted={cy.stub().as('onClearCompleted')}
/>
)
cy.get('footer')
.find('.clear-completed')
.should('be.visible')
.click()
cy.get('@onClearCompleted').should('have.been.calledOnce')
})