Skip to content

Instantly share code, notes, and snippets.

@dmsnell
Last active April 12, 2016 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmsnell/3651dd61ec3c1b3cbd5217b1c649ab92 to your computer and use it in GitHub Desktop.
Save dmsnell/3651dd61ec3c1b3cbd5217b1c649ab92 to your computer and use it in GitHub Desktop.
Taking out the test-busters
import {
newTracksEvent
} from 'analytics/actions'
export const Doohickey = ( { recordClick, hotness } ) =>
<div onClick={ recordClick( 'dingos', { hotness } ) }>Dingos!</div>
const mapDispatchToProps = dispatch => ( {
recordClick: compose( dispatch, newTracksEvent )
} )
export default connect( null, mapDispatchToProps )( Doohickey )
// actions
const newTracksEvent = ( name, options ) => ( {
type: 'RECORD_EVENT',
service: 'tracks',
name,
options,
} )
// test
import { Doohickey } from 'doohickey'
it( 'should report those dingos', () => {
const testClicker = sinon.spy()
const wrapper = mount( <Doohickey hotness={ 42 } recordClick={ testClicker } /> )
wrapper.simulate( 'click' )
expect( testClicker.args[0] ).to.eql( 'dingos' )
expect( testClicker.args[1] ).to.deep.eql( { hotness: 42 } )
} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment