mirror of
https://github.com/block/buzz.git
synced 2026-11-26 19:21:50 +00:00
Signed-off-by: npub13fn4ahfnvaa2qwylvegdgeajqs0mph6v4qsw4jcqnw4mjh3hzh2quuucm5 <8a675edd33677aa0389f6650d467b2041fb0df4ca820eacb009babb95e3715d4@sprout-oss.stage.blox.sqprod.co> Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: npub13fn4ahfnvaa2qwylvegdgeajqs0mph6v4qsw4jcqnw4mjh3hzh2quuucm5 <8a675edd33677aa0389f6650d467b2041fb0df4ca820eacb009babb95e3715d4@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
35 lines
961 B
JavaScript
35 lines
961 B
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { buildProductFeedbackEvent } from "./useSendFeedback.ts";
|
|
|
|
test("buildProductFeedbackEvent uses body and category tag", () => {
|
|
assert.deepEqual(
|
|
buildProductFeedbackEvent({ category: "bug", message: " It broke " }, []),
|
|
{ content: "It broke", tags: [["category", "bug"]] },
|
|
);
|
|
});
|
|
|
|
test("buildProductFeedbackEvent omits absent category and retains imeta", () => {
|
|
const attachment = {
|
|
url: "https://example.test/screenshot.png",
|
|
sha256: "ab".repeat(32),
|
|
size: 42,
|
|
type: "image/png",
|
|
uploaded: 42,
|
|
};
|
|
const result = buildProductFeedbackEvent(
|
|
{ category: null, message: "Useful feedback" },
|
|
[attachment],
|
|
);
|
|
assert.match(result.content, /Useful feedback/);
|
|
assert.equal(
|
|
result.tags.some((tag) => tag[0] === "category"),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
result.tags.some((tag) => tag[0] === "imeta"),
|
|
true,
|
|
);
|
|
});
|