Skip to content

Commit

Permalink
Merge pull request #33 from reedoooo/siteEdit
Browse files Browse the repository at this point in the history
  • Loading branch information
reedoooo committed Aug 28, 2023
2 parents cf9f5ed + 628a69c commit 9df3e39
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
"@iconify/react": "^4.1.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.0.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"eslint": "^8.47.0",
"eslint-config-google": "0.14.0",
"eslint-config-prettier": "^8.10.0",
Expand Down
22 changes: 18 additions & 4 deletions src/__tests__/Main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,36 @@ describe('<Main />', () => {
afterEach(cleanup);

it('should render Splash component while loading', () => {
let hasLoggedIn = false;
jest.useFakeTimers();
render(<Main onLogin={() => {}} />);
render(
<Main
onLogin={() => {
hasLoggedIn = true;
}}
/>,
);
expect(
screen.getByText(/Loading text from Splash component/),
).toBeInTheDocument(); // Replace with actual text or element from Splash component
jest.runAllTimers();
expect(hasLoggedIn).toBe(true); // Make sure onLogin was called
});

it('should render NavBar and routing after loading', async () => {
let hasLoggedIn = false;
jest.useFakeTimers();
render(<Main onLogin={() => {}} />);
render(
<Main
onLogin={() => {
hasLoggedIn = true;
}}
/>,
);
act(() => {
jest.runAllTimers();
});
expect(screen.getByText(/Text or element from NavBar/)).toBeInTheDocument(); // Replace with actual text or element from NavBar
expect(hasLoggedIn).toBe(true); // Make sure onLogin was called
});

// More tests can be added as necessary, for example, testing specific routes, or specific behaviors.
});
10 changes: 8 additions & 2 deletions src/context/ProjectContext.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { createContext } from 'react';

// Create the ProjectContext
// Empty function implementations are given comments to clarify their emptiness
export const ProjectContext = createContext({
detailsModalData: {},
detailsModalShow: false,
showDetailsModal: (data) => {},
closeDetailsModal: () => {},
showDetailsModal: (data) => {
// This is empty by default until the provider overwrites it
},
closeDetailsModal: () => {
// This is empty by default until the provider overwrites it
},
});
5 changes: 2 additions & 3 deletions src/context/ProjectsContextProvider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import { useState } from 'react';
import { ProjectContext } from './ProjectContext';

// Implement the provider for the context
export const ProjectsContextProvider = ({ children }) => {
const [detailsModalData, setDetailsModalData] = useState({});
const [detailsModalShow, setDetailsModalShow] = useState(false);
Expand All @@ -10,8 +11,6 @@ export const ProjectsContextProvider = ({ children }) => {
setDetailsModalData(project);
};

console.log('detailsModalData:', detailsModalData);

const closeDetailsModal = () => {
setDetailsModalShow(false);
};
Expand Down

0 comments on commit 9df3e39

Please sign in to comment.