We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2be3698 commit 733f057Copy full SHA for 733f057
1 file changed
‎tests/api.test.ts‎
@@ -67,6 +67,18 @@ describe('api.ts session management', () => {
67
await expect(loadSession()).rejects.toThrow(SyntaxError);
68
});
69
70
+
71
+ test('loadSession throws when reading credential file fails', async () => {
72
+ existsSyncSpy = spyOn(fs, 'existsSync').mockReturnValue(true);
73
+ readFileSyncSpy = spyOn(fs, 'readFileSync').mockImplementation(() => {
74
+ throw new Error('Read error');
75
+ });
76
77
+ await expect(loadSession()).rejects.toThrow('Read error');
78
+ expect(console.error).toHaveBeenCalledWith(
79
+ expect.stringContaining('Failed to parse file')
80
+ );
81
82
test('replaceSession sets session', () => {
83
replaceSession({ token: 'new-token' });
84
expect(getSession()?.token).toBe('new-token');
0 commit comments