From 150df382f8e0b84aa6028622480c28186c99b8a7 Mon Sep 17 00:00:00 2001
From: Sandy Tao <sandytao520@icloud.com>
Date: Fri, 27 Jun 2025 16:39:54 -0700
Subject: Upgrade to Ink 6 and React 19 (#2096)

Co-authored-by: jacob314 <jacob314@gmail.com>
---
 .../cli/src/ui/contexts/SessionContext.test.tsx    | 28 ++++++++++------------
 1 file changed, 12 insertions(+), 16 deletions(-)

(limited to 'packages/cli/src/ui/contexts/SessionContext.test.tsx')

diff --git a/packages/cli/src/ui/contexts/SessionContext.test.tsx b/packages/cli/src/ui/contexts/SessionContext.test.tsx
index e9fc33e6..fedb5341 100644
--- a/packages/cli/src/ui/contexts/SessionContext.test.tsx
+++ b/packages/cli/src/ui/contexts/SessionContext.test.tsx
@@ -6,6 +6,7 @@
 
 import { type MutableRefObject } from 'react';
 import { render } from 'ink-testing-library';
+import { renderHook } from '@testing-library/react';
 import { act } from 'react-dom/test-utils';
 import { SessionStatsProvider, useSessionStats } from './SessionContext.js';
 import { describe, it, expect, vi } from 'vitest';
@@ -223,21 +224,16 @@ describe('SessionStatsContext', () => {
   });
 
   it('should throw an error when useSessionStats is used outside of a provider', () => {
-    // Suppress the expected console error during this test.
-    const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
-
-    const contextRef = { current: undefined };
-
-    // We expect rendering to fail, which React will catch and log as an error.
-    render(<TestHarness contextRef={contextRef} />);
-
-    // Assert that the first argument of the first call to console.error
-    // contains the expected message. This is more robust than checking
-    // the exact arguments, which can be affected by React/JSDOM internals.
-    expect(errorSpy.mock.calls[0][0]).toContain(
-      'useSessionStats must be used within a SessionStatsProvider',
-    );
-
-    errorSpy.mockRestore();
+    // Suppress console.error for this test since we expect an error
+    const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
+
+    try {
+      // Expect renderHook itself to throw when the hook is used outside a provider
+      expect(() => {
+        renderHook(() => useSessionStats());
+      }).toThrow('useSessionStats must be used within a SessionStatsProvider');
+    } finally {
+      consoleSpy.mockRestore();
+    }
   });
 });
-- 
cgit v1.2.3

