Last active
April 12, 2016 16:19
-
-
Save dmsnell/3651dd61ec3c1b3cbd5217b1c649ab92 to your computer and use it in GitHub Desktop.
Taking out the test-busters
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 { | |
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