mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-12-22 04:53:17 +00:00
Fix AvatarField
Change-Id: I9614163942fcb8667885b524caf944500605c55d
This commit is contained in:
parent
3fe0e95069
commit
5b8882bd80
2 changed files with 29 additions and 1 deletions
|
@ -6,7 +6,17 @@ import { useRecordContext } from "react-admin";
|
|||
const AvatarField = ({ source, ...rest }) => {
|
||||
const record = useRecordContext(rest);
|
||||
const src = get(record, source)?.toString();
|
||||
return <Avatar src={src} {...rest} />;
|
||||
const { alt, classes, sizes, sx, variant } = rest;
|
||||
return (
|
||||
<Avatar
|
||||
alt={alt}
|
||||
classes={classes}
|
||||
sizes={sizes}
|
||||
src={src}
|
||||
sx={sx}
|
||||
variant={variant}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default AvatarField;
|
||||
|
|
18
src/components/AvatarField.test.js
Normal file
18
src/components/AvatarField.test.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
import React from "react";
|
||||
import { RecordContextProvider } from "react-admin";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import AvatarField from "./AvatarField";
|
||||
|
||||
describe("AvatarField", () => {
|
||||
it("shows image", () => {
|
||||
const value = {
|
||||
avatar: "foo",
|
||||
};
|
||||
render(
|
||||
<RecordContextProvider value={value}>
|
||||
<AvatarField source="avatar" />
|
||||
</RecordContextProvider>
|
||||
);
|
||||
expect(screen.getByRole("img").getAttribute("src")).toBe("foo");
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue