From 6b19adbb26bdc9855fb876ee066dfd0209623b0d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 21 Apr 2022 14:29:25 -0500 Subject: [PATCH] Add basic tests to containers/soapbox --- .../containers/__tests__/soapbox.test.js | 45 +++++++++++++++++++ app/soapbox/containers/soapbox.tsx | 4 +- .../components/external-login-form.tsx | 2 +- app/soapbox/features/landing_page/index.tsx | 2 +- .../features/onboarding/onboarding-wizard.tsx | 2 +- 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 app/soapbox/containers/__tests__/soapbox.test.js diff --git a/app/soapbox/containers/__tests__/soapbox.test.js b/app/soapbox/containers/__tests__/soapbox.test.js new file mode 100644 index 000000000..4c152dc33 --- /dev/null +++ b/app/soapbox/containers/__tests__/soapbox.test.js @@ -0,0 +1,45 @@ +import React from 'react'; + +import { __stub as stub } from 'soapbox/api'; +import { render, screen, waitFor } from 'soapbox/jest/test-helpers'; + +import Soapbox from '../soapbox'; + +describe('', () => { + describe('without a user or instance', () => { + beforeEach(() => { + stub(mock => { + mock.onGet('/api/v1/instance').reply(404, ''); + }); + }); + + it('renders external login', async() => { + render(); + + await waitFor(() => { + expect(location.href.endsWith('/login/external')).toBeTruthy(); + expect(screen.getByTestId('external-login')).toBeInTheDocument(); + }); + + }); + }); + + describe('without a user', () => { + beforeEach(() => { + stub(mock => { + mock.onGet('/api/v1/instance') + .reply(200, require('soapbox/__fixtures__/pleroma-instance.json')); + }); + }); + + it('renders the homepage', async() => { + render(); + + waitFor(() => { + expect(screen.getByTestId('homepage')).toBeInTheDocument(); + expect(screen.getByText('Gleasonator')).toBeInTheDocument(); + expect(screen.getByText('Speak freely.')).toBeInTheDocument(); + }); + }); + }); +}); diff --git a/app/soapbox/containers/soapbox.tsx b/app/soapbox/containers/soapbox.tsx index 03923be5c..a7223dde1 100644 --- a/app/soapbox/containers/soapbox.tsx +++ b/app/soapbox/containers/soapbox.tsx @@ -123,7 +123,7 @@ const SoapboxMount = () => { return ( - + {themeCss && } @@ -142,7 +142,7 @@ const SoapboxMount = () => { return ( - + {themeCss && } diff --git a/app/soapbox/features/external_login/components/external-login-form.tsx b/app/soapbox/features/external_login/components/external-login-form.tsx index 2d6c7d2fa..582709007 100644 --- a/app/soapbox/features/external_login/components/external-login-form.tsx +++ b/app/soapbox/features/external_login/components/external-login-form.tsx @@ -43,7 +43,7 @@ const ExternalLoginForm: React.FC = () => { } return ( -
+ { }; return ( -
+
diff --git a/app/soapbox/features/onboarding/onboarding-wizard.tsx b/app/soapbox/features/onboarding/onboarding-wizard.tsx index 7ef3cb804..bc85b63cc 100644 --- a/app/soapbox/features/onboarding/onboarding-wizard.tsx +++ b/app/soapbox/features/onboarding/onboarding-wizard.tsx @@ -67,7 +67,7 @@ const OnboardingWizard = () => { }, []); return ( -
+