/** * External dependencies */ import TestRenderer from 'react-test-renderer'; /** * Internal dependencies */ import withComponentId from '../with-component-id'; const TestComponent = withComponentId( ( props ) => { return
; } ); const render = () => { return TestRenderer.create( ); }; describe( 'withComponentId Component', () => { let renderer; it( 'initializes with expected id on initial render', () => { renderer = render(); const props = renderer.root.findByType( 'div' ).props; expect( props.componentId ).toBe( 0 ); } ); it( 'does not increment on re-render', () => { renderer.update( ); const props = renderer.root.findByType( 'div' ).props; expect( props.componentId ).toBe( 0 ); } ); it( 'increments on a new component instance', () => { renderer.update( ); const props = renderer.root.findByType( 'div' ).props; expect( props.componentId ).toBe( 1 ); } ); } );