refactor: simplify DigitalClock and TimeConverter components

This commit is contained in:
Loic Coenen
2026-06-25 10:43:36 +02:00
committed by Loic Coenen (aider)
parent 3fed6dc168
commit 0b8d76a057
5 changed files with 43 additions and 41 deletions

View File

@@ -36,15 +36,16 @@ describe("DigitalClock", () => {
expect(input).toBeDisabled();
});
it("renders the digital time and input when enabled", () => {
it("renders the input with the correct initial value when enabled", () => {
render(
<DigitalClock
currentTime={new Date(2025, 0, 1, 14, 30, 15)}
onTimeChange={onTimeChangeMock}
/>,
);
expect(screen.getByTestId("digital-clock")).toHaveTextContent("14:30:15");
expect(screen.getByTestId("time-input")).toBeInTheDocument();
const input = screen.getByTestId("time-input") as HTMLInputElement;
expect(input).toBeInTheDocument();
expect(input.value).toBe("14:30:15");
});
it("calls onTimeChange when a valid time is entered", () => {