import React, { Component } from 'react'; import { collect, WithStoreProp } from '../..'; import * as testUtils from '../testUtils'; type Props = WithStoreProp & { defaultValue: string; inputRef: React.Ref; }; const CollectedWithRef = collect((props: Props) => ( )); class ComponentWithRef extends Component { inputRef = React.createRef(); render() { return (
); } } const { getByText, getByLabelText } = testUtils.renderStrict( ); const getInputByLabelText = (text: string) => getByLabelText(text) as HTMLInputElement; it('should empty the input when the button is clicked', () => { expect(getInputByLabelText('The input').value).toBe('some text'); getInputByLabelText('The input').value = 'some different text'; expect(getInputByLabelText('The input').value).toBe('some different text'); getByText('Empty the input').click(); expect(getInputByLabelText('The input').value).toBe('X'); });