bug fix: remove unused TokenHandler component (#30084)

This commit is contained in:
Rohan Singh
2026-09-01 19:27:11 +05:30
committed by GitHub
parent 176037d0af
commit c910911772
2 changed files with 0 additions and 73 deletions
@@ -1,43 +0,0 @@
// TODO: This file is currently unused.
import { Label } from "../form/inputs/Label";
import { Input } from "../form/inputs/TextField";
type Digit = {
value: number;
onChange: () => void;
};
type Translations = {
labelText?: string;
};
type PropType = {
digits: Digit[];
digitClassName: string;
translations?: Translations;
};
const TokenHandler = ({ digits, digitClassName, translations }: PropType) => {
const { labelText = "Code" } = translations ?? {};
return (
<div>
<Label htmlFor="code">{labelText}</Label>
<div className="flex flex-row justify-between">
{digits.map((element, index) => (
<Input
key={index}
className={digitClassName}
name={`2fa${index + 1}`}
inputMode="decimal"
{...element}
autoFocus={index === 0}
autoComplete="one-time-code"
/>
))}
</div>
</div>
);
};
export default TokenHandler;
@@ -1,30 +0,0 @@
/* eslint-disable playwright/missing-playwright-await */
import { render, screen, fireEvent } from "@testing-library/react";
import { vi } from "vitest";
import TokenHandler from "./TokenHandler";
describe("Tests for TokenHandler component", () => {
test("Should render the correct number of input elements", () => {
const digits = [
{ value: 1, onChange: vi.fn() },
{ value: 2, onChange: vi.fn() },
{ value: 3, onChange: vi.fn() },
];
render(<TokenHandler digits={digits} digitClassName="digit" />);
expect(screen.getAllByRole("textbox")).toHaveLength(digits.length);
});
test("Should handle digit input correctly", () => {
const onChangeMock = vi.fn();
const digits = [{ value: 1, onChange: onChangeMock }];
render(<TokenHandler digits={digits} digitClassName="digit" />);
const inputElement = screen.getByRole("textbox");
fireEvent.change(inputElement, { target: { value: "5" } });
expect(onChangeMock).toHaveBeenCalledTimes(1);
});
});