-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from yaswanth-deriv/yaswanth/FEQ-1995_Added_t…
…est_for_inline_message_component [FEQ]Yaswanth/FEQ-1995 Added Test for inline message component
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/components/InlineMessage/__test__/InlineMessage.spec.tsx
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,52 @@ | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
import { InlineMessage } from ".."; | ||
|
||
describe("InlineMessage Component", () => { | ||
it("renders children correctly", () => { | ||
const { getByText } = render(<InlineMessage>Test Message</InlineMessage>); | ||
expect(getByText("Test Message")).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders with specified variant", () => { | ||
const { container } = render( | ||
<InlineMessage variant="error">Error Message</InlineMessage> | ||
); | ||
expect(container.firstChild).toHaveClass( | ||
"deriv-inline-message__error--filled" | ||
); | ||
}); | ||
|
||
it("renders with specified icon", () => { | ||
const { container } = render( | ||
<InlineMessage icon={<span>Icon</span>}>Message with Icon</InlineMessage> | ||
); | ||
expect(container.querySelector(".deriv-inline-message__icon")).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders with specified type", () => { | ||
const { container } = render( | ||
<InlineMessage variant="warning" type="outlined">Outlined Warning Message</InlineMessage> | ||
); | ||
expect(container.firstChild).toHaveClass( | ||
"deriv-inline-message__warning--outlined" | ||
); | ||
}); | ||
|
||
it("renders with custom class name", () => { | ||
const { container } = render( | ||
<InlineMessage className="custom-class">Custom Message</InlineMessage> | ||
); | ||
expect(container.firstChild).toHaveClass("custom-class"); | ||
}); | ||
|
||
it("should position the icon at the top", () => { | ||
const { container } = render( | ||
<InlineMessage iconPosition="top" variant="info"> | ||
Test Message | ||
</InlineMessage> | ||
); | ||
const iconElement = container.querySelector(".deriv-inline-message__icon--top") | ||
expect(iconElement).toBeInTheDocument(); | ||
}); | ||
}); |