Skip to content

Commit

Permalink
fix: should return out malformed svg in display result
Browse files Browse the repository at this point in the history
  • Loading branch information
phanshiyu committed Apr 22, 2024
1 parent 3a851f0 commit 7729e0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/components/renderer/SvgRenderer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,12 @@ describe("svgRenderer component", () => {

fireEvent.error(getByAltText("Svg image of the verified document"));

const defaultTemplate = await findByTestId("default-template", undefined, {
timeout: 5000,
});
const defaultTemplate = await findByTestId("default-template");
expect(defaultTemplate.textContent).toContain("The resolved SVG is malformedThe resolved SVG is malformed");
expect(queryByTestId("Svg image of the verified document")).not.toBeInTheDocument();
expect(mockHandleResult).toHaveBeenCalledWith({
status: "INVALID_SVG_ERROR",
svg: "",
});
});
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/renderer/SvgRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type DisplayResult =
}
| {
status: "INVALID_SVG_ERROR";
svg: string;
};

// this immediate loading state does not need to be exposed
Expand Down Expand Up @@ -217,6 +218,7 @@ const SvgRenderer = React.forwardRef<HTMLImageElement, SvgRendererProps>(
onError={() => {
handleResult({
status: "INVALID_SVG_ERROR",
svg: toDisplay.svg,
});
}}
/>
Expand Down

0 comments on commit 7729e0e

Please sign in to comment.