From 9d992b32e48625ace24789e23f814c1e4430c5f2 Mon Sep 17 00:00:00 2001
From: Anas Sulaiman <mrahs@google.com>
Date: Tue, 10 Jun 2025 18:05:44 +0000
Subject: add a unit test with multiple hunks for diff renderer

---
 .../ui/components/messages/DiffRenderer.test.tsx   | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)

(limited to 'packages/cli/src/ui/components/messages/DiffRenderer.test.tsx')

diff --git a/packages/cli/src/ui/components/messages/DiffRenderer.test.tsx b/packages/cli/src/ui/components/messages/DiffRenderer.test.tsx
index 39c327e7..c6ecc279 100644
--- a/packages/cli/src/ui/components/messages/DiffRenderer.test.tsx
+++ b/packages/cli/src/ui/components/messages/DiffRenderer.test.tsx
@@ -170,4 +170,42 @@ index abc..def 100644
     expect(output).toContain('context line 5');
     expect(output).toContain('context line 11');
   });
+
+  it('should correctly render a diff with multiple hunks and a gap indicator', () => {
+    const diffWithMultipleHunks = `
+diff --git a/multi.js b/multi.js
+index 123..789 100644
+--- a/multi.js
++++ b/multi.js
+@@ -1,3 +1,3 @@
+ console.log('first hunk');
+-const oldVar = 1;
++const newVar = 1;
+ console.log('end of first hunk');
+@@ -20,3 +20,3 @@
+ console.log('second hunk');
+-const anotherOld = 'test';
++const anotherNew = 'test';
+ console.log('end of second hunk');
+`;
+    const { lastFrame } = render(
+      <DiffRenderer diffContent={diffWithMultipleHunks} filename="multi.js" />,
+    );
+    const output = lastFrame();
+
+    // Check for content from the first hunk
+    expect(output).toContain("1      console.log('first hunk');");
+    expect(output).toContain('2    - const oldVar = 1;');
+    expect(output).toContain('2    + const newVar = 1;');
+    expect(output).toContain("3      console.log('end of first hunk');");
+
+    // Check for the gap indicator between hunks
+    expect(output).toContain('═');
+
+    // Check for content from the second hunk
+    expect(output).toContain("20     console.log('second hunk');");
+    expect(output).toContain("21   - const anotherOld = 'test';");
+    expect(output).toContain("21   + const anotherNew = 'test';");
+    expect(output).toContain("22     console.log('end of second hunk');");
+  });
 });
-- 
cgit v1.2.3

