Skip to content

Commit

Permalink
Merge pull request #146 from yaswanth-deriv/yaswanth/FEQ-1995_Added_t…
Browse files Browse the repository at this point in the history
…est_for_inline_message_component

[FEQ]Yaswanth/FEQ-1995 Added Test for inline message component
  • Loading branch information
shayan-deriv authored Apr 1, 2024
2 parents b29ce82 + af328dc commit 55f25bd
Showing 1 changed file with 52 additions and 0 deletions.
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();
});
});

0 comments on commit 55f25bd

Please sign in to comment.