Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEQ]Yaswanth/FEQ-1995 Added Test for inline message component #146

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/components/InlineMessage/__test__/InlineMessage.spec.tsx
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();
});
});