forked from deriv-com/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInlineMessage.spec.tsx
52 lines (46 loc) · 1.68 KB
/
InlineMessage.spec.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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();
});
});