UNPKG

@uva-glass/component-library

Version:

React components UvA

26 lines (25 loc) 1.42 kB
import { jsx as a } from "react/jsx-runtime"; import "../../index-dmBn99rF.js"; import { r as n, s as t, f as r } from "../../react.esm-DI5ilWeT.js"; import { userEvent as s } from "../../index-DXR-TB1d.js"; import { TextArea as o } from "./TextArea.js"; describe("TextArea", () => { it("should render correctly with label", () => { n(/* @__PURE__ */ a(o, { onChange: jest.fn(), label: "Test Label" })), expect(t.getByText("Test Label")).toBeInTheDocument(); }), it("should call onChange when text is entered", () => { const e = jest.fn(); n(/* @__PURE__ */ a(o, { onChange: e })); const l = t.getByRole("textbox"); r.input(l, { target: { value: "Hello" } }), expect(e).toHaveBeenCalledWith("Hello"); }), it("should update character count", () => { n(/* @__PURE__ */ a(o, { onChange: jest.fn(), label: "Test", maxCharacters: 10 })); const e = t.getByRole("textbox"); r.input(e, { target: { value: "Test" } }), expect(t.getByText("4")).toBeInTheDocument(), expect(t.getByText("/ 10")).toBeInTheDocument(); }), it("should not exceed max characters limit", async () => { const e = jest.fn(); n(/* @__PURE__ */ a(o, { onChange: e, maxCharacters: 5 })); const l = t.getByRole("textbox"); await s.type(l, "ExceedsLimit"), expect(e).toHaveBeenCalled(), expect(e.mock.calls[e.mock.calls.length - 1][0].length).toBe(5); }); }); //# sourceMappingURL=TextArea.test.js.map