|
@@ -42,7 +42,7 @@ describe("Image Component", () => {
|
|
|
});
|
|
|
it("displays the default label", async () => {
|
|
|
const { getByAltText } = render(
|
|
|
- <Image defaultContent="/url/toto.png" defaultLabel="titi" label={undefined as unknown as string} />
|
|
|
+ <Image defaultContent="/url/toto.png" defaultLabel="titi" label={undefined as unknown as string} />,
|
|
|
);
|
|
|
getByAltText("titi");
|
|
|
});
|
|
@@ -82,17 +82,17 @@ describe("Image Component", () => {
|
|
|
type: "SEND_ACTION_ACTION",
|
|
|
});
|
|
|
});
|
|
|
- it("should return [undefined, undefined, false] when content prop is not provided", () => {
|
|
|
+ it("URL used when content prop is not provided", () => {
|
|
|
const { getByRole } = render(<Image defaultContent="/url/to/default/image.png" />);
|
|
|
const img = getByRole("img") as HTMLImageElement;
|
|
|
expect(img.src).toBe("http://localhost/url/to/default/image.png");
|
|
|
});
|
|
|
- it("should return [undefined, undefined, false] when content prop is an empty string", () => {
|
|
|
+ it("URL replaced when content prop is an empty string", () => {
|
|
|
const { getByRole } = render(<Image defaultContent="/url/to/default/image.png" content="" />);
|
|
|
const img = getByRole("img") as HTMLImageElement;
|
|
|
expect(img.src).toBe("http://localhost/");
|
|
|
});
|
|
|
- it("should return [undefined, undefined, false] when content prop is a string of length less than 4", () => {
|
|
|
+ it("URL replaced when content prop is a string of length less than 4", () => {
|
|
|
const { getByRole } = render(<Image defaultContent="/url/to/default/image.png" content="abc" />);
|
|
|
const img = getByRole("img") as HTMLImageElement;
|
|
|
expect(img.src).toBe("http://localhost/abc");
|
|
@@ -111,13 +111,13 @@ describe("Image Component", () => {
|
|
|
const svg = container.querySelector("svg");
|
|
|
expect(svg?.outerHTML.replace(/"/g, "'")).toBe(svgContent.replace(/"/g, "'"));
|
|
|
});
|
|
|
- it("should return the content prop when it is SVG XML", () => {
|
|
|
+ it("should return the content prop when it is inline SVG", () => {
|
|
|
const content = "<svg xmlns='http://www.w3.org/2000/svg'></svg>";
|
|
|
const { container } = render(<Image defaultContent="/url/to/default/image.png" content={content} />);
|
|
|
const svg = container.querySelector("svg");
|
|
|
expect(svg?.outerHTML.replace(/"/g, "'")).toBe(content);
|
|
|
});
|
|
|
- it("should return the content prop when it is a string of length 4 or more that is not a SVG file or SVG XML", () => {
|
|
|
+ it("should return the content prop in the general case", () => {
|
|
|
const { getByRole } = render(
|
|
|
<Image defaultContent="/url/to/default/image.png" content="/url/to/content/image.png" />,
|
|
|
);
|
|
@@ -137,13 +137,13 @@ describe("Image Component", () => {
|
|
|
const div = container.querySelector("div");
|
|
|
expect(div).toBeInTheDocument();
|
|
|
});
|
|
|
- it("should render a div when content prop is SVG XML", () => {
|
|
|
+ it("should render a div when content prop is inline SVG", () => {
|
|
|
const content = "<svg xmlns='http://www.w3.org/2000/svg'></svg>";
|
|
|
const { container } = render(<Image defaultContent="/url/to/default/image.png" content={content} />);
|
|
|
const div = container.querySelector("div");
|
|
|
expect(div).toBeInTheDocument();
|
|
|
});
|
|
|
- it("should render an img when content prop is not a SVG file or SVG XML", () => {
|
|
|
+ it("should render an img when content prop is not SVG", () => {
|
|
|
const { getByRole } = render(
|
|
|
<Image defaultContent="/url/to/default/image.png" content="/url/to/content/image.png" />,
|
|
|
);
|