forked from cypress-io/cypress-react-unit-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.js
33 lines (30 loc) · 908 Bytes
/
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
import React from 'react'
import { mount } from 'cypress-react-unit-test'
import Contact from './contact'
import Map from './map'
it('should render contact information', () => {
// mock Map component used by Contact component
// whenever React tries to instantiate using Map constructor
// call DummyMap constructor
const DummyMap = props => (
<div data-testid="map">
DummyMap {props.center.lat}:{props.center.long}
</div>
)
cy.stub(React, 'createElement')
.callThrough()
.withArgs(Map)
.callsFake((constructor, props) => React.createElement(DummyMap, props))
cy.viewport(500, 500)
const center = { lat: 0, long: 0 }
mount(
<Contact
name="Joni Baez"
email="[email protected]"
site="http://test.com"
center={center}
/>,
)
cy.contains('Contact Joni Baez via')
cy.contains('[data-testid="map"]', '0:0').should('be.visible')
})