From 58be9c457b72c03ba2f290214fbb282a5ab87c30 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 25 Sep 2024 12:05:07 -0400 Subject: [PATCH] test: login with github Signed-off-by: Adam Setch --- src/routes/Accounts.test.tsx | 15 +++++++------- src/routes/Accounts.tsx | 2 +- src/routes/Login.test.tsx | 20 +++++++++++++++++++ .../__snapshots__/Accounts.test.tsx.snap | 2 +- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/routes/Accounts.test.tsx b/src/routes/Accounts.test.tsx index 768c7f25f..0c3ee7e5f 100644 --- a/src/routes/Accounts.test.tsx +++ b/src/routes/Accounts.test.tsx @@ -239,12 +239,15 @@ describe('routes/Accounts.tsx', () => { describe('Add new accounts', () => { it('should show login with github app', async () => { + const mockLoginWithGitHubApp = jest.fn(); + await act(async () => { render( @@ -254,9 +257,9 @@ describe('routes/Accounts.tsx', () => { ); }); - expect(screen.getByTitle('Login with GitHub App').hidden).toBe(false); + fireEvent.click(screen.getByTitle('Login with GitHub')); - fireEvent.click(screen.getByTitle('Login with GitHub App')); + expect(mockLoginWithGitHubApp).toHaveBeenCalled(); }); it('should show login with personal access token', async () => { @@ -275,11 +278,8 @@ describe('routes/Accounts.tsx', () => { ); }); - expect(screen.getByTitle('Login with Personal Access Token').hidden).toBe( - false, - ); - fireEvent.click(screen.getByTitle('Login with Personal Access Token')); + expect(mockNavigate).toHaveBeenNthCalledWith( 1, '/login-personal-access-token', @@ -305,9 +305,8 @@ describe('routes/Accounts.tsx', () => { ); }); - expect(screen.getByTitle('Login with OAuth App').hidden).toBe(false); - fireEvent.click(screen.getByTitle('Login with OAuth App')); + expect(mockNavigate).toHaveBeenNthCalledWith(1, '/login-oauth-app', { replace: true, }); diff --git a/src/routes/Accounts.tsx b/src/routes/Accounts.tsx index ae8ffc8b8..e906ce1a9 100644 --- a/src/routes/Accounts.tsx +++ b/src/routes/Accounts.tsx @@ -186,7 +186,7 @@ export const AccountsRoute: FC = () => {