diff --git a/ghost/portal/src/components/SignedInPage.js b/ghost/portal/src/components/SignedInPage.js
index 921aabc5dd..ff68f85f55 100644
--- a/ghost/portal/src/components/SignedInPage.js
+++ b/ghost/portal/src/components/SignedInPage.js
@@ -144,7 +144,7 @@ export default class SignedInPage extends React.Component {
renderLogoutButton() {
return (
-
{
+
{
this.handleSignout(e);
}} style={{fontWeight: 'bold'}}> Logout
diff --git a/ghost/portal/src/components/SignedInPage.test.js b/ghost/portal/src/components/SignedInPage.test.js
index 0d5107b48e..db4e4b8391 100644
--- a/ghost/portal/src/components/SignedInPage.test.js
+++ b/ghost/portal/src/components/SignedInPage.test.js
@@ -1,18 +1,38 @@
import React from 'react';
-import {render} from '@testing-library/react';
+import {render, fireEvent} from '@testing-library/react';
import SignedInPage from './SignedInPage';
import {site, member} from '../test/fixtures/data';
+const setup = (overrides) => {
+ const mockOnActionFn = jest.fn();
+ const mockSwitchPageFn = jest.fn();
+
+ const utils = render(
+
+ );
+ const memberEmail = utils.getByText(member.email);
+ const logoutButton = utils.queryByRole('button', {name: 'Logout'});
+ return {
+ memberEmail,
+ logoutButton,
+ mockOnActionFn,
+ mockSwitchPageFn,
+ ...utils
+ };
+};
+
describe('SignedInPage', () => {
test('renders', () => {
- const {getByText} = render(
-
{}} switchPage={() => {}} />
- );
-
- const memberEmail = getByText(member.email);
- const logoutButton = getByText(/logout/i);
+ const {memberEmail, logoutButton} = setup();
expect(memberEmail).toBeInTheDocument();
expect(logoutButton).toBeInTheDocument();
});
+
+ test('can call signout', () => {
+ const {mockOnActionFn, logoutButton} = setup();
+
+ fireEvent.click(logoutButton);
+ expect(mockOnActionFn).toHaveBeenCalledWith('signout');
+ });
});