From 18fc18761dbefc2ab2fbaf93e1fe433eb0b47b37 Mon Sep 17 00:00:00 2001
From: Norton <2773923088@qq。>
Date: Mon, 6 Apr 2026 14:32:33 +0800
Subject: A small portion of newly added unit testing code

---
 src/components/ui/input.test.tsx | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'src/components/ui/input.test.tsx')

diff --git a/src/components/ui/input.test.tsx b/src/components/ui/input.test.tsx
index aabe76f..036352b 100644
--- a/src/components/ui/input.test.tsx
+++ b/src/components/ui/input.test.tsx
@@ -1,6 +1,8 @@
 import { render, screen } from '@testing-library/react';
 import { describe, expect, test } from 'vitest';
 import { Input } from './input';
+import userEvent from '@testing-library/user-event';
+import { vi } from 'vitest';
 
 describe('Input', () => {
   test('renders an input with the expected slot attribute', () => {
@@ -18,5 +20,19 @@ describe('Input', () => {
     expect(input).toHaveAttribute('type', 'password');
     expect(input).toBeDisabled();
   });
+
+  test('handles user typing and triggers onChange event', async () => {
+    const user = userEvent.setup();
+    const handleChange = vi.fn();
+
+    render(<Input aria-label="Username" onChange={handleChange} />);
+    const input = screen.getByLabelText('Username');
+
+    await user.type(input, 'hello world');
+
+    expect(input).toHaveValue('hello world');
+    expect(handleChange).toHaveBeenCalled();
+    expect(handleChange).toHaveBeenCalledTimes(11);
+  });
 });
 
-- 
cgit v1.2.3

