From 529ca33a347d5ae7ee0ed7052d05230255873de9 Mon Sep 17 00:00:00 2001 From: Nick Williams Date: Mon, 16 Apr 2018 15:19:00 +0100 Subject: [PATCH] Add `testId` prop for use as a test hook Rather than allow arbitrary `data-*` attributes, I thought a simpler solution would be to have a specific prop for `testId`. Draft-js has a similar approach --- src/components/ModalPortal.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/ModalPortal.js b/src/components/ModalPortal.js index c31d62e7..c48b8241 100644 --- a/src/components/ModalPortal.js +++ b/src/components/ModalPortal.js @@ -54,7 +54,8 @@ export default class ModalPortal extends Component { children: PropTypes.node, shouldCloseOnEsc: PropTypes.bool, overlayRef: PropTypes.func, - contentRef: PropTypes.func + contentRef: PropTypes.func, + testId: PropTypes.string }; constructor(props) { @@ -346,6 +347,7 @@ export default class ModalPortal extends Component { role={this.props.role} aria-label={this.props.contentLabel} {...this.ariaAttributes(this.props.aria || {})} + data-testid={this.props.testId} > {this.props.children}