-
Notifications
You must be signed in to change notification settings - Fork 90
Add @testing-library/react and component tests #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
3a28f7a
7b3775b
9d0099e
d7dacd5
8c95b3b
1ae80bd
bb5571c
e4c1763
f051d2e
eaaebb2
95f6058
a8938c3
de1b4e6
d3ebdea
5ed5f2e
d0d4463
3b0d8d9
b0200c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`TeamSidebar should render when show is false 1`] = `<div />`; | ||
|
|
||
| exports[`TeamSidebar should render when show is true 1`] = ` | ||
| <div> | ||
| <div> | ||
| <a | ||
| href="https://gitlab.com" | ||
| rel="noopener noreferrer" | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| target="_blank" | ||
| > | ||
| <i | ||
| class="fa fa-gitlab fa-lg" | ||
| /> | ||
| </a> | ||
| <a | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <svg | ||
| height="13" | ||
| viewBox="0 0 16 16" | ||
| width="13" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| clip-rule="evenodd" | ||
| d="M10.34 1.22a.75.75 0 0 0-1.06 0L7.53 2.97 7 3.5l.53.53 1.75 1.75a.75.75 0 1 0 1.06-1.06l-.47-.47h.63c.69 0 1.25.56 1.25 1.25v4.614a2.501 2.501 0 1 0 1.5 0V5.5a2.75 2.75 0 0 0-2.75-2.75h-.63l.47-.47a.75.75 0 0 0 0-1.06ZM13.5 12.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm-9 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm1.5 0a2.5 2.5 0 1 1-3.25-2.386V5.886a2.501 2.501 0 1 1 1.5 0v4.228A2.501 2.501 0 0 1 6 12.5Zm-1.5-9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z" | ||
| fill="rgba(51,51,51,0.6)" | ||
| fill-rule="evenodd" | ||
| /> | ||
| </svg> | ||
| <span | ||
| style="margin-left: 2px;" | ||
| > | ||
| 0 | ||
| </span> | ||
| </a> | ||
| <a | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <svg | ||
| height="13" | ||
| viewBox="0 0 16 16" | ||
| width="13" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| clip-rule="evenodd" | ||
| d="M9 2.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm1.45-.5a2.5 2.5 0 0 0-4.9 0H3a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1h-2.55ZM8 5H5.5V3.5h-2v11h9v-11h-2V5H8ZM5 7.75A.75.75 0 0 1 5.75 7h4.5a.75.75 0 0 1 0 1.5h-4.5A.75.75 0 0 1 5 7.75Zm.75 1.75a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z" | ||
| fill="rgba(51,51,51,0.6)" | ||
| fill-rule="evenodd" | ||
| /> | ||
| </svg> | ||
| <span | ||
| style="margin-left: 2px;" | ||
| > | ||
| 0 | ||
| </span> | ||
| </a> | ||
| <a | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <svg | ||
| height="13" | ||
| viewBox="0 0 16 16" | ||
| width="13" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| clip-rule="evenodd" | ||
| d="M3 2.5h6a.5.5 0 0 1 .5.5v10a.5.5 0 0 1-.5.5H3a.5.5 0 0 1-.5-.5V3a.5.5 0 0 1 .5-.5ZM1 3a2 2 0 0 1 2-2h6a2 2 0 0 1 1.97 1.658l2.913 1.516a1.75 1.75 0 0 1 .744 2.36l-3.878 7.45a.753.753 0 0 1-.098.145c-.36.526-.965.871-1.651.871H3a2 2 0 0 1-2-2V3Zm10 7.254 2.297-4.413a.25.25 0 0 0-.106-.337L11 4.364v5.89Z" | ||
| fill="rgba(51,51,51,0.6)" | ||
| fill-rule="evenodd" | ||
| /> | ||
| </svg> | ||
| <span | ||
| style="margin-left: 2px;" | ||
| > | ||
| 0 | ||
| </span> | ||
| </a> | ||
| <a | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <svg | ||
| height="13" | ||
| viewBox="0 0 16 16" | ||
| width="13" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| clip-rule="evenodd" | ||
| d="M3 13.5a.5.5 0 0 1-.5-.5V3a.5.5 0 0 1 .5-.5h9.25a.75.75 0 0 0 0-1.5H3a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V9.75a.75.75 0 0 0-1.5 0V13a.5.5 0 0 1-.5.5H3Zm12.78-8.82a.75.75 0 0 0-1.06-1.06L9.162 9.177 7.289 7.241a.75.75 0 1 0-1.078 1.043l2.403 2.484a.75.75 0 0 0 1.07.01L15.78 4.68Z" | ||
| fill="rgba(51,51,51,0.6)" | ||
| fill-rule="evenodd" | ||
| /> | ||
| </svg> | ||
| <span | ||
| style="margin-left: 2px;" | ||
| > | ||
| 0 | ||
| </span> | ||
| </a> | ||
| <a | ||
| href="#" | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <i | ||
| class="fa fa-refresh fa-spin" | ||
| /> | ||
| </a> | ||
| </div> | ||
| </div> | ||
| `; |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {describe, expect, test} from '@jest/globals'; | ||
| import {render} from '@testing-library/react'; | ||
| import {configureStore, createSlice} from '@reduxjs/toolkit'; | ||
|
|
||
| import {Provider} from 'react-redux'; | ||
|
|
||
| import TeamSidebar from './team_sidebar'; | ||
|
|
||
| const mockTheme = { | ||
| sidebarBg: '#ffffff', | ||
| sidebarText: '#333333', | ||
| sidebarUnreadText: '#ff0000', | ||
| sidebarTextHoverBg: '#eeeeee', | ||
| sidebarTextActiveBorder: '#007bff', | ||
| sidebarTextActiveColor: '#007bff', | ||
| sidebarHeaderBg: '#f8f9fa', | ||
| sidebarHeaderTextColor: '#495057', | ||
| onlineIndicator: '#28a745', | ||
| awayIndicator: '#ffc107', | ||
| dndIndicator: '#dc3545', | ||
| mentionBg: '#ffeb3b', | ||
| mentionBj: '#ffeb3b', | ||
| mentionColor: '#333333', | ||
| centerChannelBg: '#f8f9fa', | ||
| centerChannelColor: '#333333', | ||
| newMessageSeparator: '#007bff', | ||
| linkColor: '#007bff', | ||
| buttonBg: '#007bff', | ||
| buttonColor: '#ffffff', | ||
| errorTextColor: '#dc3545', | ||
| mentionHighlightBg: '#ffeb3b', | ||
| mentionHighlightLink: '#007bff', | ||
| codeTheme: 'solarized-dark', | ||
| }; | ||
|
|
||
| const mockSlice = createSlice({ | ||
| name: 'mock-reducer', | ||
| initialState: { | ||
| 'plugins-com.github.manland.mattermost-plugin-gitlab': { | ||
| connected: true, | ||
| username: '', | ||
| clientId: '', | ||
| lhsData: { | ||
| reviews: [], | ||
| yourAssignedPrs: [], | ||
| yourAssignedIssues: [], | ||
| todos: [], | ||
| }, | ||
| gitlabURL: '', | ||
| organization: '', | ||
| rhsPluginAction: () => true, | ||
|
Comment on lines
42
to
56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why If we are setting
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mickmister , I have set values to the Kindly take a look at it. |
||
| }, | ||
| entities: {general: {config: {}}}, | ||
| }, | ||
| reducers: {}, | ||
| }); | ||
|
|
||
| const mockStore = configureStore({ | ||
| reducer: mockSlice.reducer, | ||
| }); | ||
|
|
||
| describe('TeamSidebar', () => { | ||
| test.each([true, false])('should render when show is %s', (show) => { | ||
| const {container} = render( | ||
| <Provider store={mockStore}> | ||
| <TeamSidebar | ||
| show={show} | ||
| theme={mockTheme} | ||
| /> | ||
| </Provider>, | ||
| ); | ||
|
|
||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React, {FC} from 'react'; | ||
|
|
||
| import {Theme} from 'mattermost-redux/types/preferences'; | ||
|
|
||
| import SidebarButtons from '../sidebar_buttons'; | ||
|
|
||
| interface TeamSidebarProps { | ||
| show: boolean; | ||
| theme: Theme; | ||
| } | ||
|
|
||
| const TeamSidebar: FC<TeamSidebarProps> = ({show, theme}: TeamSidebarProps) => { | ||
| if (!show) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <SidebarButtons | ||
| theme={theme} | ||
| isTeamSidebar={true} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default TeamSidebar; | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.