From 6ba4f342b2b0140095c01d523bf16ddb660040a0 Mon Sep 17 00:00:00 2001 From: Afonso Jorge Ramos Date: Mon, 5 Jun 2023 20:22:13 +0100 Subject: [PATCH] chore: improve tests for sidebar --- src/components/Logo.tsx | 3 +- src/components/Sidebar.test.tsx | 30 ++++++++++++++++++- src/components/Sidebar.tsx | 1 + .../__snapshots__/Sidebar.test.tsx.snap | 2 ++ src/utils/constants.ts | 2 +- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/components/Logo.tsx b/src/components/Logo.tsx index 3afa0ffd4..1193ba820 100644 --- a/src/components/Logo.tsx +++ b/src/components/Logo.tsx @@ -12,7 +12,7 @@ const LIGHT_GRADIENT_END = '#FFFFFF'; const DARK_GRADIENT_START = '#22283B'; const DARK_GRADIENT_END = '#555B6E'; -export const Logo = ({ isDark, onClick, className = '' }: IProps) => ( +export const Logo = ({ isDark, onClick, className = '', ...props }: IProps) => ( onClick && onClick()} @@ -20,6 +20,7 @@ export const Logo = ({ isDark, onClick, className = '' }: IProps) => ( xmlnsXlink="http://www.w3.org/1999/xlink" viewBox="0 0 500 500" role="logo" + {...props} > { ); }); + it('should quit the app', () => { + const { getByLabelText } = render( + + + + + + ); + fireEvent.click(getByLabelText('Quit App')); + expect(ipcRenderer.send).toHaveBeenCalledTimes(1); + expect(ipcRenderer.send).toHaveBeenCalledWith('app-quit'); + }); + + it('should open the gitify repository', () => { + render( + + + + + + ); + fireEvent.click(screen.getByTestId('gitify-logo')); + expect(shell.openExternal).toHaveBeenCalledTimes(1); + expect(shell.openExternal).toHaveBeenCalledWith( + 'https://github.com/gitify-app/gitify' + ); + }); + describe('should render the notifications icon', () => { it('when there are 0 notifications', () => { const { getByLabelText } = render( diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index c0a404e15..c5cf4e712 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -43,6 +43,7 @@ export const Sidebar: React.FC = () => {
diff --git a/src/components/__snapshots__/Sidebar.test.tsx.snap b/src/components/__snapshots__/Sidebar.test.tsx.snap index 682ebbb10..5ff88d128 100644 --- a/src/components/__snapshots__/Sidebar.test.tsx.snap +++ b/src/components/__snapshots__/Sidebar.test.tsx.snap @@ -9,6 +9,7 @@ exports[`components/Sidebar.tsx should render itself & its children (logged in) >