cal/packages/ui/components/avatar/UserAvatar.test.tsx
sean-brydon 698d8ae4bd
chore: front-end-avatars (#12716)
* Update UserAvatar and remove org avatar

* Update Imports

* Fix imports to use calcom/ui

* type: fix imports

* fix: use testId on profile

* test: use image src instead of innerHTML

* fix: Allow alt on useravatar

* test: add testId to org profile

---------

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2024-01-05 10:36:44 +00:00

38 lines
1.1 KiB
TypeScript

/* eslint-disable playwright/missing-playwright-await */
import { render } from "@testing-library/react";
import { AVATAR_FALLBACK } from "@calcom/lib/constants";
import { UserAvatar } from "./UserAvatar";
const mockUser = {
name: "John Doe",
username: "pro",
organizationId: null,
};
describe("tests for UserAvatar component", () => {
test("Should render the UsersAvatar Correctly", () => {
const { getByTestId } = render(<UserAvatar user={mockUser} data-testid="user-avatar-test" />);
const avatar = getByTestId("user-avatar-test");
expect(avatar).toBeInTheDocument();
});
test("It should render the organization logo if a organization is passed in", () => {
const { getByTestId } = render(
<UserAvatar
user={mockUser}
organization={{ id: -1, requestedSlug: "steve", slug: "steve", logoUrl: AVATAR_FALLBACK }}
data-testid="user-avatar-test"
/>
);
const avatar = getByTestId("user-avatar-test");
const organizationLogo = getByTestId("organization-logo");
expect(avatar).toBeInTheDocument();
expect(organizationLogo).toBeInTheDocument();
});
});