Skip to content

Commit 828aa48

Browse files
authored
feat: Add data-cy and data-testid props for test support (#296)
* Add support for data-cy for e2e tests * Add support for testid
1 parent 04dcaca commit 828aa48

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lib/index.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ class SingleOtpInput extends PureComponent {
8686
style={{ display: 'flex', alignItems: 'center' }}
8787
>
8888
<input
89-
aria-label={`${
90-
index === 0 ? 'Please enter verification code. ' : ''
91-
}${isInputNum ? 'Digit' : 'Character'} ${index + 1}`}
89+
aria-label={`${index === 0 ? 'Please enter verification code. ' : ''
90+
}${isInputNum ? 'Digit' : 'Character'} ${index + 1}`}
9291
autoComplete="off"
9392
style={Object.assign(
9493
{ width: '1em', textAlign: 'center' },
@@ -334,6 +333,8 @@ class OtpInput extends Component {
334333
isInputNum={isInputNum}
335334
isInputSecure={isInputSecure}
336335
className={className}
336+
data-cy={this.props["data-cy"] ? `${this.props["data-cy"]}-${i}` : null}
337+
data-testid={this.props["data-testid"] ? `${this.props["data-testid"]}-${i}` : null}
337338
/>
338339
);
339340
}

0 commit comments

Comments
 (0)