Last active
April 21, 2016 23:22
-
-
Save StevenLangbroek/1b2fd82654639e24de6f395da93e0dfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { connect } from 'react-redux'; | |
import ProductBody from 'components/ProductBody'; | |
import ProductImages from 'components/ProductImages'; | |
import { openProduct } from 'reducers/product'; | |
const ProductDetail = ({ | |
product, | |
handleProductClick | |
}) => ( | |
<div className="product" onClick={handleProductClick}> | |
<ProductImages images={product.get('images')} onSomeEvent={handleProductClick} /> | |
<ProductBody productProperties={product.get('properties')} onMoreClick={handleProductClick} /> | |
</div> | |
); | |
const mapStateToProps = (state, { params: { productId }}) => { | |
const product = getEntities(state).getIn(['products', parseInt(productId, 10)]); | |
return { | |
product | |
}; | |
}; | |
const mapDispatchToProps = { | |
handleProductClick: openProduct | |
}; | |
export defaultconnect(mapStateToProps, mapDispatchToProps)(ProductDetail); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ProductBody from 'components/ProductBody'; | |
import { shallow } from 'enzyme'; | |
describe('<ProductBody />', () => { | |
it('calls click succesfully', () => { | |
const product = { | |
id: 1, | |
title: 'Awesome product' | |
}; | |
const subject = sinon.spy(); | |
const component = shallow(<ProductBody product={product} onMoreClick={clickSpy} />); | |
component.find('.some-el').simulate('click'); | |
expext(clickSpy).to.be.calledOnce.and.calledWith(product.id); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment