const ConfirmModalView = ({ handleAccept, handleCancel, body, acceptText, cancelText, fadeOut, }: Props) => ( <Modal confirm fadeOut={fadeOut}> <Modal.Blur /> <Modal.Content> <p>{body}</p> </Modal.Content> <Modal.Footer> <Button onClick={handleAccept}> {acceptText} </Button> <Button flat onClick={handleCancel}> {cancelText} </Button> </Modal.Footer> </Modal> )
expect(wrapper.find(Modal.Blur)).toHaveLength(1); expect(wrapper.find(Modal.Content)).toHaveLength(1); expect(wrapper.find(Modal.Footer)).toHaveLength(1); }); expect(wrapper.find(Modal.Footer).find(Button)).toHaveLength(2); expect(wrapper.find(Modal.Footer).find(Button).at(0).text()).toBe('Accept'); expect(wrapper.find(Modal.Footer).find(Button).at(1).text()).toBe('Cancel'); }); wrapper.find(Modal.Footer).find(Button).at(0).simulate('click'); wrapper.find(Modal.Footer).find(Button).at(1).simulate('click');
const ModalView = ({ handleModalCancel, handleModalSubmit, content, title, submitText, cancelText, submitDisabled, }: Props) => ( <Modal> <Modal.Blur /> <Modal.Header> <H1 secondary>{title}</H1> <button onClick={handleModalCancel}> <i className="fas fa-times" /> </button> </Modal.Header> <Modal.Content> {content} </Modal.Content> <Modal.Footer hidden={!submitText}> <Button disabled={submitDisabled} onClick={handleModalSubmit}> {submitText} </Button> <Button flat onClick={handleModalCancel}> {cancelText} </Button> </Modal.Footer> </Modal> )
expect(wrapper.find(Modal.Header)).toHaveLength(1); expect(wrapper.find(Modal.Content)).toHaveLength(1); expect(wrapper.find(Modal.Footer)).toHaveLength(1); }); expect(wrapper.find(Modal.Footer).find(Button)).toHaveLength(2); expect(wrapper.find(Modal.Footer).find(Button).at(0).text()).toBe('Submit'); expect(wrapper.find(Modal.Footer).find(Button).at(1).text()).toBe('Cancel'); }); wrapper.find(Modal.Footer).find(Button).at(0).simulate('click'); wrapper.find(Modal.Footer).find(Button).at(1).simulate('click'); wrapper.find(Modal.Header).find('button').simulate('click');