Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions packages/elements/__tests__/tool.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,40 @@ describe("toolOutput", () => {
);
expect(screen.getByText("Result")).toBeInTheDocument();
});

it("renders empty-string output", () => {
render(
<Tool>
<ToolOutput errorText={undefined} output="" />
</Tool>
);
expect(screen.getByText("Result")).toBeInTheDocument();
});

it("renders zero output", () => {
render(
<Tool>
<ToolOutput errorText={undefined} output={0} />
</Tool>
);
expect(screen.getByText("Result")).toBeInTheDocument();
});

it("renders false output", () => {
render(
<Tool>
<ToolOutput errorText={undefined} output={false} />
</Tool>
);
expect(screen.getByText("Result")).toBeInTheDocument();
});

it("renders nothing when output is null", () => {
const { container } = render(
<Tool>
<ToolOutput errorText={undefined} output={null} />
</Tool>
);
expect(container.textContent).toBe("");
});
});
2 changes: 1 addition & 1 deletion packages/elements/src/tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const ToolOutput = ({
errorText,
...props
}: ToolOutputProps) => {
if (!(output || errorText)) {
if ((output === undefined || output === null) && !errorText) {
return null;
}

Expand Down