-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathdocument.cy.jsx
More file actions
41 lines (37 loc) · 1.02 KB
/
document.cy.jsx
File metadata and controls
41 lines (37 loc) · 1.02 KB
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
/// <reference types="cypress" />
import React from 'react'
import { mount } from '@cypress/react'
// example from https://github.com/bahmutov/cypress-react-unit-test/issues/52
const DocumentTest = ({ reportHeight }) => {
return (
<div>
<button
onClick={() => {
return reportHeight(
document.documentElement.clientHeight,
document.body.clientHeight,
)
}}
>
Report height
</button>
</div>
)
}
describe('DocumentTest', () => {
it('has valid dimensions', () => {
const reportHeight = cy.stub().as('report')
mount(<DocumentTest reportHeight={reportHeight} />)
cy.get('button').click()
cy.get('@report')
.should('have.been.called')
.its('firstCall.args')
.then(([docElementHeight, docBodyHeight]) => {
expect(docElementHeight)
.to.be.gt(0)
.and.equal(Cypress.config('viewportHeight'))
// contains a single DIV, so probably more than 10px
expect(docBodyHeight).to.be.gt(10)
})
})
})