import React from "react";
import { render } from "@testing-library/react-native";
import Avatar, { AvatarProps } from "./avatar";
import { ThemeProvider } from "../../../theme/src/theme-context";
import Icon, { IconProps } from "../../atoms/icon/icon";
import withBadge from "../badge/withBadge";
import Stack from "../../atoms/stack/stack";
import AvatarGroup from "./avatar-group";
jest.useFakeTimers();
describe("Molecules/Avatar", () => {
it("passes the snapshot test for different sizes", () => {
const tree = render(
<>
>
).toJSON();
expect(tree).toMatchSnapshot();
});
it("passes the snapshot test for fallback support", () => {
const tree = render(
}
/>
).toJSON();
expect(tree).toMatchSnapshot();
});
it("withBadge HOC works as expected", () => {
const Wrapper = () => {
const OnlineAvatar = withBadge(undefined, {
placement: "bottomRight",
backgroundColor: "success.500",
size: "s",
minW: 15,
h: 15,
offset: 0,
})(Avatar);
const OfflineAvatar = withBadge(0, {
placement: "bottomRight",
backgroundColor: "danger.500",
size: "s",
offset: 0,
})(Avatar);
const AvatarWithEdit = withBadge(
,
{
placement: "bottomRight",
size: "m",
onPress: () => {
console.log("PRESSED!");
},
}
)(Avatar);
return (
);
};
const root = render(
);
const tree = root.toJSON();
expect(tree).toMatchSnapshot();
expect(root.getByText("0")).toBeTruthy();
});
it("passes the snapshot test when used in a group", () => {
const tree = render(
).toJSON();
expect(tree).toMatchSnapshot();
});
});