Skip to content

Commit c381a0a

Browse files
authored
Merge pull request #26 from LukeWlodarczyk/feature/dataCy
feat: add support for dataCy prop
2 parents 70ae40d + 8ba7220 commit c381a0a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Props = {
1616
onCompleted?: (data: string) => void;
1717
placeholder?: string;
1818
value?: string;
19+
dataCy?: string;
1920
};
2021

2122
const ReactInputVerificationCode = ({
@@ -25,6 +26,7 @@ const ReactInputVerificationCode = ({
2526
onCompleted = () => {},
2627
placeholder = '·',
2728
value: pValue,
29+
dataCy = 'verification-code'
2830
}: Props) => {
2931
const emptyValue = new Array(length).fill(placeholder);
3032

@@ -197,6 +199,7 @@ const ReactInputVerificationCode = ({
197199
onBlur={onInputBlur}
198200
// needed for styling
199201
activeIndex={activeIndex}
202+
data-cy={`${dataCy}-otc-input`}
200203
/>
201204

202205
{itemsRef.map((ref, i) => (
@@ -209,6 +212,7 @@ const ReactInputVerificationCode = ({
209212
value[i] !== placeholder ? 'is-filled' : ''
210213
} ${i === activeIndex ? 'is-active' : ''}`}
211214
onFocus={onItemFocus(i)}
215+
data-cy={`${dataCy}-${i}-item`}
212216
>
213217
{value[i] || placeholder}
214218
</Item>

0 commit comments

Comments
 (0)