From 733f05712bdf991da82aa8c4512efc3645057d73 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 16:07:50 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A7=AA=20Add=20test=20for=20error=20p?= =?UTF-8?q?ath=20in=20loadSession?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> --- tests/api.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/api.test.ts b/tests/api.test.ts index 1ae3751..194b7e0 100644 --- a/tests/api.test.ts +++ b/tests/api.test.ts @@ -67,6 +67,18 @@ describe('api.ts session management', () => { await expect(loadSession()).rejects.toThrow(SyntaxError); }); + + test('loadSession throws when reading credential file fails', async () => { + existsSyncSpy = spyOn(fs, 'existsSync').mockReturnValue(true); + readFileSyncSpy = spyOn(fs, 'readFileSync').mockImplementation(() => { + throw new Error('Read error'); + }); + + await expect(loadSession()).rejects.toThrow('Read error'); + expect(console.error).toHaveBeenCalledWith( + expect.stringContaining('Failed to parse file') + ); + }); test('replaceSession sets session', () => { replaceSession({ token: 'new-token' }); expect(getSession()?.token).toBe('new-token'); From 03685695781e5588aa3ff2970b8f4e9affb3e16f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 16:10:06 +0000 Subject: [PATCH 2/2] Fix linting errors Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> --- tests/api.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/api.test.ts b/tests/api.test.ts index 194b7e0..cdd4b7c 100644 --- a/tests/api.test.ts +++ b/tests/api.test.ts @@ -67,7 +67,6 @@ describe('api.ts session management', () => { await expect(loadSession()).rejects.toThrow(SyntaxError); }); - test('loadSession throws when reading credential file fails', async () => { existsSyncSpy = spyOn(fs, 'existsSync').mockReturnValue(true); readFileSyncSpy = spyOn(fs, 'readFileSync').mockImplementation(() => { @@ -76,7 +75,7 @@ describe('api.ts session management', () => { await expect(loadSession()).rejects.toThrow('Read error'); expect(console.error).toHaveBeenCalledWith( - expect.stringContaining('Failed to parse file') + expect.stringContaining('Failed to parse file'), ); }); test('replaceSession sets session', () => {