Skip to content

Commit dbbf7ca

Browse files
committed
test: add test for caretHidden prop
- add test case to ensure caret is not rendered when caretHidden is true - add testID to Caret component for easier testing
1 parent e374712 commit dbbf7ca

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/__tests__/text-input-otp.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ describe('TextInputOTP Component', () => {
2525
const mockedOnFilled = jest.fn();
2626
const view = render({ onFilled: mockedOnFilled });
2727
fireEvent.changeText(view.getByTestId('hidden-text-input'), CODE);
28-
2928
expect(mockedOnFilled).toHaveBeenCalledWith(CODE);
3029
});
30+
31+
it('should not render the animated caret when caretHidden prop is true', () => {
32+
const view = render({ caretHidden: true });
33+
expect(view.queryByTestId('caret')).toBeNull();
34+
});
3135
});

src/components/caret.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export function Caret() {
2626

2727
return (
2828
<Animated.View
29+
testID="caret"
2930
style={[
3031
styles.caret,
3132
{ opacity, backgroundColor: caretColor ?? DEFAULT_DARK_COLOR },

0 commit comments

Comments
 (0)