From 6857802f9aefafc0be53978d28e333caee0ef09a Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Thu, 8 Oct 2026 16:57:21 -0700 Subject: [PATCH] test: simplify GitHub CLI mock responses --- .../utils/forges/github/cli-auth.test.ts | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/renderer/utils/forges/github/cli-auth.test.ts b/src/renderer/utils/forges/github/cli-auth.test.ts index e1eb6ee0c..b06e81eb9 100644 --- a/src/renderer/utils/forges/github/cli-auth.test.ts +++ b/src/renderer/utils/forges/github/cli-auth.test.ts @@ -25,24 +25,21 @@ describe('GitHub CLI credential lifecycle', () => { const authorization = options.headers.authorization; requests.push({ url, authorization }); const rejected = authorization === `token ${rejectedToken}`; - return new Response( - JSON.stringify( - rejected - ? { message: 'Bad credentials' } - : url.endsWith('/user') - ? { - id: - authorization === 'token different-user' - ? 'different-user' - : mockGitHubCliAccount.user?.id, - } - : [], - ), - { - status: rejected ? 401 : 200, - headers: { 'content-type': 'application/json' }, - }, - ); + let body: unknown = []; + if (rejected) { + body = { message: 'Bad credentials' }; + } else if (url.endsWith('/user')) { + body = { + id: + authorization === 'token different-user' + ? 'different-user' + : mockGitHubCliAccount.user?.id, + }; + } + return new Response(JSON.stringify(body), { + status: rejected ? 401 : 200, + headers: { 'content-type': 'application/json' }, + }); }), ); return requests;