Skip to content

Commit

Permalink
add more tests for disabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
EddWills95 committed Jan 18, 2024
1 parent 61a3f34 commit 244112c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/OtpInput/OtpInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ describe("OtpInput", () => {

const inputs = screen.getAllByTestId("otp-input");
expect(inputs[0]).not.toHaveTextContent("1");
inputs.forEach((i) => expect(i).toBeDisabled());

const hiddenInput = screen.getByTestId("otp-input-hidden");
expect(hiddenInput).toBeDisabled();
});

test("focusColor should not be overridden by theme", () => {
Expand Down
3 changes: 3 additions & 0 deletions src/OtpInput/OtpInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const OtpInput = forwardRef<OtpInputRef, OtpInputProps>((props, ref) => {
return (
<Pressable
key={`${char}-${index}`}
disabled={disabled}
onPress={handlePress}
style={[
styles.codeContainer,
Expand Down Expand Up @@ -89,6 +90,8 @@ export const OtpInput = forwardRef<OtpInputRef, OtpInputProps>((props, ref) => {
style={styles.hiddenInput}
secureTextEntry={secureTextEntry}
autoComplete="one-time-code"
aria-disabled={disabled}
editable={!disabled}
testID="otp-input-hidden"
/>
</View>
Expand Down
1 change: 1 addition & 0 deletions src/OtpInput/__snapshots__/OtpInput.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ exports[`OtpInput UI should render correctly 1`] = `
<TextInput
autoComplete="one-time-code"
autoFocus={true}
editable={true}
inputMode="numeric"
maxLength={6}
onChangeText={[Function]}
Expand Down

0 comments on commit 244112c

Please sign in to comment.