From a81577bcf6834b5ecc07376b77d96829d5c0744f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 15 Jan 2023 13:07:42 -0600 Subject: [PATCH] Test public layout header --- .../components/__tests__/header.test.tsx | 32 +++++++++++++++++++ .../public-layout/components/header.tsx | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/soapbox/features/public-layout/components/__tests__/header.test.tsx diff --git a/app/soapbox/features/public-layout/components/__tests__/header.test.tsx b/app/soapbox/features/public-layout/components/__tests__/header.test.tsx new file mode 100644 index 000000000..d69198efa --- /dev/null +++ b/app/soapbox/features/public-layout/components/__tests__/header.test.tsx @@ -0,0 +1,32 @@ +import React from 'react'; + +import { storeOpen, storePepeOpen } from 'soapbox/jest/mock-stores'; +import { render, screen } from 'soapbox/jest/test-helpers'; + +import Header from '../header'; + +describe('
', () => { + it('successfully renders', () => { + render(
); + expect(screen.getByTestId('public-layout-header')).toBeInTheDocument(); + }); + + it('doesn\'t display the signup button by default', () => { + render(
); + expect(screen.queryByText('Register')).not.toBeInTheDocument(); + }); + + describe('with registrations enabled', () => { + it('displays the signup button', () => { + render(
, undefined, storeOpen); + expect(screen.getByText('Register')).toBeInTheDocument(); + }); + }); + + describe('with registrations closed, Pepe enabled', () => { + it('displays the signup button', () => { + render(
, undefined, storePepeOpen); + expect(screen.getByText('Register')).toBeInTheDocument(); + }); + }); +}); \ No newline at end of file diff --git a/app/soapbox/features/public-layout/components/header.tsx b/app/soapbox/features/public-layout/components/header.tsx index ad3accc83..e771fe5cd 100644 --- a/app/soapbox/features/public-layout/components/header.tsx +++ b/app/soapbox/features/public-layout/components/header.tsx @@ -65,7 +65,7 @@ const Header = () => { if (mfaToken) return ; return ( -
+