From 889c57f5e4e07e5d3ad143a064efd1f82f4b1916 Mon Sep 17 00:00:00 2001 From: leowrites Date: Wed, 16 Oct 2024 21:28:21 -0400 Subject: [PATCH] add tests for long strings --- memory-viz/src/tests/draw.spec.tsx | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/memory-viz/src/tests/draw.spec.tsx b/memory-viz/src/tests/draw.spec.tsx index c907e5b..e2d4af7 100644 --- a/memory-viz/src/tests/draw.spec.tsx +++ b/memory-viz/src/tests/draw.spec.tsx @@ -907,4 +907,44 @@ describe("draw function", () => { }) ).toThrow(errorMessage); }); + + it("renders an appropriately sized box for a very long string", () => { + const objects: DrawnEntity[] = [ + { + id: 1, + type: "str", + value: "I am a very very very very very very very very very very very very very very very very very very very very very very very very very very very long string", + }, + ]; + const output: InstanceType = draw(objects, true, { + width: 100, + roughjs_config: { + options: { + seed: 12345, + }, + }, + }); + const svg: string = output.serializeSVG(); + expect(svg).toMatchSnapshot(); + }); + it("renders an appropriately sized box for a string with the highlight style", () => { + const objects: DrawnEntity[] = [ + { + id: 1, + type: "str", + value: "I am a very very very very very very very very very very very very very very very very very very very very very very very very very very very long string", + style: ["highlight"], + }, + ]; + const output: InstanceType = draw(objects, true, { + width: 100, + roughjs_config: { + options: { + seed: 12345, + }, + }, + }); + const svg: string = output.serializeSVG(); + expect(svg).toMatchSnapshot(); + }); });