-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for Button and ButtonLink components
A new test file, Button.component.test.tsx, has been added for the Button component to validate if it renders a button and correctly displays the provided children as text. Tests in ButtonLink.component.test.tsx have been reorganized for clarity. The tests now more clearly verify rendering of a link and the display of children as text in the ButtonLink component.
- Loading branch information
Showing
2 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
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,23 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
import Button from "./Button.tsx"; | ||
|
||
test("Button component renders a button", () => { | ||
render( | ||
<Button buttonType="delete" handleOnClick={() => {}}> | ||
Delete | ||
</Button> | ||
); | ||
const button = screen.getByRole("button"); | ||
expect(button).toBeInTheDocument(); | ||
}); | ||
|
||
test("Button component renders children as text", () => { | ||
render( | ||
<Button buttonType="delete" handleOnClick={() => {}}> | ||
Delete | ||
</Button> | ||
); | ||
const text = screen.getByText(/delete/i); | ||
expect(text).toBeInTheDocument(); | ||
}); |
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