mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(user): avatar icon not shown in User component (#3387)
* chore(deps): pnpm-lock.yaml * fix(user): avoid passing user name to avatar component * feat(changeset): add changeset * feat(user): add avatar icon test cases
This commit is contained in:
parent
3cdfb2afca
commit
c5ab49afa4
5
.changeset/real-falcons-care.md
Normal file
5
.changeset/real-falcons-care.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@nextui-org/user": patch
|
||||
---
|
||||
|
||||
removed `name` from `avatarProps` in `use-user.ts` (#3369)
|
||||
@ -3,6 +3,7 @@ import {render} from "@testing-library/react";
|
||||
import {Link} from "@nextui-org/link";
|
||||
|
||||
import {User} from "../src";
|
||||
import {AvatarIcon} from "../../avatar/src";
|
||||
|
||||
describe("User", () => {
|
||||
it("should render correctly", () => {
|
||||
@ -20,9 +21,11 @@ describe("User", () => {
|
||||
|
||||
it("should have the passed name", () => {
|
||||
const {container} = render(<User name="Test" />);
|
||||
const name = container.querySelector("span");
|
||||
const spans = container.querySelectorAll("span");
|
||||
|
||||
expect(name).toHaveTextContent("Test");
|
||||
expect(spans).toHaveLength(4);
|
||||
|
||||
expect(spans[2]).toHaveTextContent("Test");
|
||||
});
|
||||
|
||||
it("should have the passed description", () => {
|
||||
@ -72,4 +75,31 @@ describe("User", () => {
|
||||
|
||||
expect(wrapper.getByTestId("test-user-link")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should render avatar icon", () => {
|
||||
const {container} = render(
|
||||
<User
|
||||
avatarProps={{
|
||||
icon: <AvatarIcon />,
|
||||
}}
|
||||
name="test"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.querySelector("svg")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should display initials in avatar if name is specified", () => {
|
||||
const {getByRole} = render(
|
||||
<User
|
||||
avatarProps={{
|
||||
icon: <AvatarIcon />,
|
||||
name: "WK",
|
||||
}}
|
||||
name="test"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(getByRole("img")).toHaveTextContent("WK");
|
||||
});
|
||||
});
|
||||
|
||||
@ -66,7 +66,6 @@ export function useUser(props: UseUserProps) {
|
||||
|
||||
const avatarProps = {
|
||||
isFocusable: false,
|
||||
name: typeof name === "string" ? name : undefined,
|
||||
...userAvatarProps,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user