mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-24 23:05:49 +00:00
test(extensions): cover malformed marketplace details
This commit is contained in:
@@ -38,6 +38,28 @@ describe("formatMarketplaceHttpError", () => {
|
||||
).toBe("Marketplace request failed (HTTP 409): Extension version already exists");
|
||||
});
|
||||
|
||||
it("prefers a string error when both JSON detail fields are present", () => {
|
||||
expect(
|
||||
formatMarketplaceHttpError({
|
||||
status: 400,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ error: "Primary detail", message: "Secondary detail" }),
|
||||
}),
|
||||
).toBe("Marketplace request failed (HTTP 400): Primary detail");
|
||||
});
|
||||
|
||||
it("hides malformed JSON bodies", () => {
|
||||
const body = '{"error":"internal route details"';
|
||||
const message = formatMarketplaceHttpError({
|
||||
status: 400,
|
||||
contentType: "application/json",
|
||||
body,
|
||||
});
|
||||
|
||||
expect(message).toBe("Marketplace request failed (HTTP 400).");
|
||||
expect(message).not.toContain(body);
|
||||
});
|
||||
|
||||
it("bounds long JSON details and marks truncation without splitting Unicode", () => {
|
||||
const detail = `🚀${"x".repeat(200)}`;
|
||||
const message = formatMarketplaceHttpError({
|
||||
|
||||
Reference in New Issue
Block a user