-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KLAR-8155] Add char counter to textarea (#536)
* init * renamne * improve styles * Empty-Commit * update * add tests * fix typo
- Loading branch information
Showing
5 changed files
with
104 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as React from "react"; | ||
import "@testing-library/jest-dom/extend-expect"; | ||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { Textarea } from "../Textarea"; | ||
|
||
test("displays correct character count", () => { | ||
render(<Textarea maxCharCount={20} />); | ||
|
||
expect(screen.getByText("20 / 20")).toBeInTheDocument(); | ||
|
||
userEvent.type(screen.getByRole("textbox"), "Strawberry"); | ||
expect(screen.getByText("10 / 20")).toBeInTheDocument(); | ||
}); | ||
|
||
// https://github.com/testing-library/user-event/issues/591#issuecomment-517816296 | ||
test("maxCharCount sets maxLength property", () => { | ||
render(<Textarea maxCharCount={10} />); | ||
|
||
expect(screen.getByRole("textbox")).toHaveProperty("maxLength"); | ||
}); |