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
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,19 @@ describe("DefiLlamaActionProvider", () => {
const result = await provider.searchProtocols({ query: "UNISWAP" });
expect(JSON.parse(result)).toEqual(mockProtocols);
});

it("should ignore protocol entries without a name", async () => {
fetchMock.mockResolvedValue({
ok: true,
json: jest.fn().mockResolvedValue([
{ tvl: 1000 },
...mockProtocols,
]),
});

const result = await provider.searchProtocols({ query: "uniswap" });

expect(JSON.parse(result)).toEqual(mockProtocols);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ Important notes:
}

const protocols = await response.json();
const searchResults = protocols.filter((protocol: Protocol) =>
protocol.name.toLowerCase().includes(args.query.toLowerCase()),
const searchResults = protocols.filter(
(protocol: Protocol) =>
typeof protocol?.name === "string" &&
protocol.name.toLowerCase().includes(args.query.toLowerCase()),
);

if (searchResults.length === 0) {
Expand Down
Loading