From 38d5dfe96a0a49cb6b75da9a446bff5171f2fad3 Mon Sep 17 00:00:00 2001 From: Pablo Tovar Date: Mon, 12 Jan 2026 19:54:00 +0100 Subject: [PATCH] test: move about command coverage --- tests/commands.users.test.ts | 51 ------------------------------------ 1 file changed, 51 deletions(-) diff --git a/tests/commands.users.test.ts b/tests/commands.users.test.ts index a17de69..bdf7271 100644 --- a/tests/commands.users.test.ts +++ b/tests/commands.users.test.ts @@ -9,7 +9,6 @@ const baseCtx = { resolveRelayBaseUrlFromOptions: () => 'https://relay.example', resolveProfileNameFromOptions: () => undefined, p: () => '', - l: () => '', printTweets: () => undefined, } as unknown as CliContext; @@ -210,54 +209,4 @@ describe('users commands', () => { expect(payload.nextCursor).toBeNull(); expect(followingSpy).toHaveBeenCalledTimes(2); }); - - it('prints account info JSON for about command', async () => { - const program = new Command(); - registerUserCommands(program, baseCtx); - vi.spyOn(TwitterClient.prototype, 'getUserAboutAccount').mockResolvedValue({ - success: true, - aboutProfile: { - accountBasedIn: 'Spain', - source: 'Spain App Store', - createdCountryAccurate: true, - locationAccurate: false, - learnMoreUrl: 'https://help.twitter.com/profile', - }, - }); - - const logSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined); - await program.parseAsync(['node', 'bird', 'about', 'pablotovar_', '--json']); - - const payload = JSON.parse(String(logSpy.mock.calls[0]?.[0])); - expect(payload).toEqual({ - accountBasedIn: 'Spain', - source: 'Spain App Store', - createdCountryAccurate: true, - locationAccurate: false, - learnMoreUrl: 'https://help.twitter.com/profile', - }); - }); - - it('exits on about command failure', async () => { - const program = new Command(); - registerUserCommands(program, baseCtx); - const exitSpy = vi.spyOn(process, 'exit').mockImplementation(((code?: number) => { - throw new Error(`exit ${code}`); - }) as never); - const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined); - vi.spyOn(TwitterClient.prototype, 'getUserAboutAccount').mockResolvedValue({ - success: false, - error: 'Missing about_profile in response', - }); - - try { - await expect(program.parseAsync(['node', 'bird', 'about', 'pablotovar__'])).rejects.toThrow('exit 1'); - expect(errorSpy).toHaveBeenCalledWith( - expect.stringContaining('Failed to fetch account information: Missing about_profile in response'), - ); - } finally { - exitSpy.mockRestore(); - errorSpy.mockRestore(); - } - }); });