Skip to content

Commit

Permalink
fix: fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
wang9hu committed Jun 8, 2024
1 parent b832bc7 commit abdd460
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
10 changes: 1 addition & 9 deletions src/components/Projects/Overview/Overview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* This component display the number of projects and active projects
********************************************************************************/
import React from 'react';
import { connect } from 'react-redux';
import { PROJECTS, ACTIVE_PROJECTS } from './../../../languages/en/ui';

const Overview = props => {
Expand Down Expand Up @@ -33,11 +32,4 @@ const Overview = props => {
);
};

const mapStateToProps = state => {
return {
numberOfProjects: state.allProjects.projects.length,
numberOfActive: state.allProjects.projects.filter(project => project.isActive).length,
};
}

export default connect(mapStateToProps)(Overview);
export default Overview
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('ProjectTableHeader Component', () => {
});

// Test case to check if the delete column is shown for users with delete permission
it('shows delete column for users with delete permission', () => {
it('shows archive column for users with delete permission', () => {
const stateWithDeletePermission = {
...sampleProps,
userProfile: {
Expand All @@ -75,7 +75,7 @@ describe('ProjectTableHeader Component', () => {
const hasPermission = jest.fn((a) => true)
stateWithDeletePermission.hasPermission = hasPermission;
const { getByText } = renderProjectTableHeader(stateWithDeletePermission);
expect(getByText('Delete')).toBeInTheDocument();
expect(getByText('Archive')).toBeInTheDocument();
});

// Test case to check if the delete column is not shown for users without delete permission
Expand Down
4 changes: 3 additions & 1 deletion src/components/Projects/Projects.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import EditableInfoModal from '../UserProfile/EditableModal/EditableInfoModal';
const Projects = function(props) {
const role = props.state.userProfile.role;
const { darkMode } = props.state.theme;
const numberOfProjects = props.state.allProjects.projects.length;
const numberOfActive = props.state.allProjects.projects.filter(project => project.isActive).length;
const { fetching, fetched, status, error } = props.state.allProjects;
const initialModalData = {
showModal: false,
Expand Down Expand Up @@ -160,7 +162,7 @@ const Projects = function(props) {
/>
</div>

<Overview />
<Overview numberOfProjects={numberOfProjects} numberOfActive={numberOfActive} />
{canPostProject ? <AddProject onAddNewProject={postProject} /> : null}

<table className="table table-bordered table-responsive-sm">
Expand Down

0 comments on commit abdd460

Please sign in to comment.