forked from calcom/cal.com
-
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.
test: Create unit tests for react components in packages/ui/component…
…s/alert (tests-alert-component) (calcom#9897) Co-authored-by: gitstart-calcom <[email protected]>
- Loading branch information
1 parent
02e34a7
commit bd7eadd
Showing
5 changed files
with
67 additions
and
0 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
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,41 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
import { Alert } from "./Alert"; | ||
|
||
describe("Tests for Alert component", () => { | ||
test("Should render text", () => { | ||
render(<Alert severity="info" title="I'm an Alert!" message="Hello World" />); | ||
expect(screen.getByText("I'm an Alert!")).toBeInTheDocument(); | ||
expect(screen.getByText("Hello World")).toBeInTheDocument(); | ||
}); | ||
|
||
test("Should render actions", () => { | ||
render(<Alert severity="info" actions={<button>Click Me</button>} />); | ||
expect(screen.getByText("Click Me")).toBeInTheDocument(); | ||
}); | ||
|
||
test("Should render corresponding icon: error", () => { | ||
render(<Alert severity="error" />); | ||
expect(screen.getByTestId("x-circle")).toBeInTheDocument(); | ||
}); | ||
|
||
test("Should render corresponding icon: warning", () => { | ||
render(<Alert severity="warning" />); | ||
expect(screen.getByTestId("alert-triangle")).toBeInTheDocument(); | ||
}); | ||
|
||
test("Should render corresponding icon: info", () => { | ||
render(<Alert severity="info" />); | ||
expect(screen.getByTestId("info")).toBeInTheDocument(); | ||
}); | ||
|
||
test("Should render corresponding icon: neutral", () => { | ||
render(<Alert severity="neutral" />); | ||
expect(screen.getByTestId("neutral")).toBeInTheDocument(); | ||
}); | ||
|
||
test("Should render corresponding icon: success", () => { | ||
render(<Alert severity="success" />); | ||
expect(screen.getByTestId("check-circle-2")).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import matchers from "@testing-library/jest-dom/matchers"; | ||
import { cleanup } from "@testing-library/react"; | ||
import { afterEach, expect } from "vitest"; | ||
|
||
expect.extend(matchers); | ||
|
||
afterEach(() => { | ||
cleanup(); | ||
}); |
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