Skip to content

Commit

Permalink
remove test for setting the max length cause its a browser behaviour …
Browse files Browse the repository at this point in the history
…and shouldnt be test
  • Loading branch information
m0dh4x committed Dec 10, 2024
1 parent a5b370b commit 0b33234
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions app/components/inputs/__test__/Textarea.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,11 @@ describe("Textarea component", () => {
expect(textarea.getAttribute("rows")).toEqual(TEXT_AREA_ROWS.toString());
});

it("should set the maxLength and enforce it", () => {
it("should set the maxLength", () => {
const maxLength = 10;
getInputProps.mockImplementationOnce(() => ({
id: "componentName",
maxLength: maxLength,
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => {
e.target.value = e.target.value.slice(0, maxLength);
},
}));

const RemixStub = createRemixStub([
Expand All @@ -190,18 +187,10 @@ describe("Textarea component", () => {

render(<RemixStub />);

const textarea = screen.getByRole<HTMLTextAreaElement>("textbox");

fireEvent.change(textarea, {
target: { value: "This is a very long text" },
});

expect(getInputProps).toHaveBeenCalledWith(
expect.objectContaining({
maxLength: maxLength,
}),
);
expect(textarea.value.length).toEqual(maxLength);
expect(textarea.value).toEqual("This is a ");
});
});

0 comments on commit 0b33234

Please sign in to comment.