Skip to content

Commit

Permalink
test: add suit for default number of inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
anday013 committed Mar 5, 2024
1 parent 71868e1 commit 3d28189
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion dist/src/OtpInput/OtpInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const react_native_1 = require("@testing-library/react-native");
const React = require("react");
const OtpInput_1 = require("./OtpInput");
const renderOtpInput = (props) => (0, react_native_1.render)(<OtpInput_1.OtpInput numberOfDigits={6} {...props}/>);
const renderOtpInput = (props) => (0, react_native_1.render)(<OtpInput_1.OtpInput {...props}/>);
describe("OtpInput", () => {
describe("UI", () => {
test("should render correctly", () => {
Expand All @@ -24,6 +24,11 @@ describe("OtpInput", () => {
expect(input).toHaveTextContent("•");
});
});
test("should have 6 inputs by default", () => {
renderOtpInput();
const inputs = react_native_1.screen.getAllByTestId("otp-input");
expect(inputs).toHaveLength(6);
});
test("should autoFocused by default", () => {
renderOtpInput();
const input = react_native_1.screen.getByTestId("otp-input-hidden");
Expand Down
11 changes: 9 additions & 2 deletions src/OtpInput/OtpInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import * as React from "react";
import { OtpInput } from "./OtpInput";
import { OtpInputProps, OtpInputRef } from "./OtpInput.types";

const renderOtpInput = (props?: Partial<OtpInputProps>) =>
render(<OtpInput numberOfDigits={6} {...props} />);
const renderOtpInput = (props?: Partial<OtpInputProps>) => render(<OtpInput {...props} />);

describe("OtpInput", () => {
describe("UI", () => {
Expand Down Expand Up @@ -34,6 +33,14 @@ describe("OtpInput", () => {
});
});

test("should have 6 inputs by default", () => {
renderOtpInput();

const inputs = screen.getAllByTestId("otp-input");

expect(inputs).toHaveLength(6);
});

test("should autoFocused by default", () => {
renderOtpInput();

Expand Down

0 comments on commit 3d28189

Please sign in to comment.