-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.test.tsx
32 lines (28 loc) · 1.05 KB
/
input.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { render, screen } from "@testing-library/react";
import { createRef } from "react";
import { describe, expect, it } from "vitest";
import { Input } from "./input";
describe("Input", () => {
it("renders without crashing", () => {
render(<Input />);
const inputElement = screen.getByRole("textbox");
expect(inputElement).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = createRef<HTMLInputElement>();
render(<Input ref={ref} />);
expect(ref.current).not.toBeNull();
});
it("renders startIcon correctly", () => {
const StartIcon = () => <div data-testid="start-icon" />;
render(<Input startIcon={<StartIcon />} />);
const startIconElement = screen.getByTestId("start-icon");
expect(startIconElement).toBeInTheDocument();
});
it("renders endIcon correctly", () => {
const EndIcon = () => <div data-testid="end-icon" />;
render(<Input endIcon={<EndIcon />} />);
const endIconElement = screen.getByTestId("end-icon");
expect(endIconElement).toBeInTheDocument();
});
});