From 5b8882bd805e5558a72b46abe17d77600f1ad8b0 Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Wed, 7 Feb 2024 13:30:02 +0100 Subject: [PATCH] Fix AvatarField Change-Id: I9614163942fcb8667885b524caf944500605c55d --- src/components/AvatarField.js | 12 +++++++++++- src/components/AvatarField.test.js | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/components/AvatarField.test.js diff --git a/src/components/AvatarField.js b/src/components/AvatarField.js index 32dff83..8e71531 100644 --- a/src/components/AvatarField.js +++ b/src/components/AvatarField.js @@ -6,7 +6,17 @@ import { useRecordContext } from "react-admin"; const AvatarField = ({ source, ...rest }) => { const record = useRecordContext(rest); const src = get(record, source)?.toString(); - return ; + const { alt, classes, sizes, sx, variant } = rest; + return ( + + ); }; export default AvatarField; diff --git a/src/components/AvatarField.test.js b/src/components/AvatarField.test.js new file mode 100644 index 0000000..8e815fa --- /dev/null +++ b/src/components/AvatarField.test.js @@ -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( + + + + ); + expect(screen.getByRole("img").getAttribute("src")).toBe("foo"); + }); +});