diff --git a/src/shared/global-singleton.test.ts b/src/shared/global-singleton.test.ts index 3d537f5cc4b..34b4e8817f3 100644 --- a/src/shared/global-singleton.test.ts +++ b/src/shared/global-singleton.test.ts @@ -52,4 +52,14 @@ describe("resolveGlobalMap", () => { expect(resolveGlobalMap(TEST_MAP_KEY).get("a")).toBe(1); }); + + it("reuses a prepopulated global map without creating a new one", () => { + const existing = new Map([["a", 1]]); + (globalThis as Record)[TEST_MAP_KEY] = existing; + + const resolved = resolveGlobalMap(TEST_MAP_KEY); + + expect(resolved).toBe(existing); + expect(resolved.get("a")).toBe(1); + }); }); diff --git a/src/shared/text/code-regions.test.ts b/src/shared/text/code-regions.test.ts index 05934383bd2..2a9c2a05360 100644 --- a/src/shared/text/code-regions.test.ts +++ b/src/shared/text/code-regions.test.ts @@ -27,13 +27,25 @@ describe("shared/text/code-regions", () => { expect(text.slice(regions[1].start, regions[1].end)).toBe("```\nunterminated"); }); + it("keeps adjacent inline code outside fenced regions", () => { + const text = ["```ts", "const a = 1;", "```", "after `inline` tail"].join("\n"); + + const regions = findCodeRegions(text); + + expect(regions).toHaveLength(2); + expect(text.slice(regions[0].start, regions[0].end)).toContain("```ts"); + expect(text.slice(regions[1].start, regions[1].end)).toBe("`inline`"); + }); + it("reports whether positions are inside discovered regions", () => { const text = "plain `code` done"; const regions = findCodeRegions(text); const codeStart = text.indexOf("code"); const plainStart = text.indexOf("plain"); + const regionEnd = regions[0]?.end ?? -1; expect(isInsideCode(codeStart, regions)).toBe(true); expect(isInsideCode(plainStart, regions)).toBe(false); + expect(isInsideCode(regionEnd, regions)).toBe(false); }); });