aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/InputText.test.tsx
blob: 8acf6f26d21f157d6d851749f7e31a45cacdb369 (plain)
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
33
34
35
36
/**
 * @vitest-environment jsdom
 */
import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, test } from "vitest";
import InputText from "./InputText";

afterEach(() => {
  cleanup();
});

describe("InputText", () => {
  test("renders an input element", () => {
    render(<InputText data-testid="input" />);
    const input = screen.getByTestId("input");
    expect(input.tagName).toBe("INPUT");
  });

  test("passes placeholder prop", () => {
    render(<InputText placeholder="Enter text" data-testid="input" />);
    const input = screen.getByTestId("input") as HTMLInputElement;
    expect(input.placeholder).toBe("Enter text");
  });

  test("passes type prop", () => {
    render(<InputText type="password" data-testid="input" />);
    const input = screen.getByTestId("input") as HTMLInputElement;
    expect(input.type).toBe("password");
  });

  test("has border styling", () => {
    render(<InputText data-testid="input" />);
    const input = screen.getByTestId("input");
    expect(input.className).toContain("border-brand-600");
  });
});