Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

test: cover mismatched reply fence markers

Mohammad Maraqad831e4806852
diff --git a/src/lib/formatted-reply.test.ts b/src/lib/formatted-reply.test.ts
index 04b9e7cac5..a51ce65496 100644
--- a/src/lib/formatted-reply.test.ts
+++ b/src/lib/formatted-reply.test.ts
@@ -30,13 +30,24 @@ describe("splitReplyBlocks", () => {
it.each(["`", "~"])("keeps tables inside longer %s fences as code", (character) => {
const outer = character.repeat(4);
- const fenced = [`${outer}md`, character.repeat(3), table, `${outer} still code`, table, character.repeat(5)].join("\n");
+ const opposite = character === "`" ? "~~~~" : "````";
+ const fenced = [
+ `${outer}md`, character.repeat(3), opposite, table, `${outer} still code`, table, character.repeat(5),
+ ].join("\n");
expect(splitReplyBlocks(`${fenced}\n\n${table}`)).toEqual([
{ kind: "prose", text: fenced },
{ kind: "table", text: table },
]);
});
+ it("keeps tables outside an invalid backtick fence visible", () => {
+ const invalidFence = "```md`example";
+ expect(splitReplyBlocks(`${invalidFence}\n\n${table}`)).toEqual([
+ { kind: "prose", text: invalidFence },
+ { kind: "table", text: table },
+ ]);
+ });
+
it("keeps a reply with no table as one prose block", () => {
expect(splitReplyBlocks("Hello\n\n- one\n- two")).toEqual([{ kind: "prose", text: "Hello\n\n- one\n- two" }]);
});