-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into DESENG-490-Fontawesome
- Loading branch information
Showing
19 changed files
with
1,381 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'mock-file-stub'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React, { ReactNode } from 'react'; | ||
import { render, waitFor, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { Form } from 'components/FormCAC/Form'; | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
import { FormContext } from 'components/FormCAC/FormContext'; | ||
|
||
jest.mock('@mui/lab/TabContext/TabContext', () => { | ||
// Create a mock component | ||
return { | ||
__esModule: true, | ||
default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>, | ||
}; | ||
}); | ||
|
||
jest.mock('@mui/lab/TabPanel/TabPanel', () => { | ||
// Create a mock component | ||
return { | ||
__esModule: true, | ||
default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>, | ||
}; | ||
}); | ||
|
||
jest.mock('@mui/material', () => ({ | ||
...jest.requireActual('@mui/material'), | ||
Link: ({ children }: { children: ReactNode }) => { | ||
return <a>{children}</a>; | ||
}, | ||
})); | ||
// Mock hooks and services | ||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
useNavigate: () => jest.fn(), | ||
useParams: () => ({ | ||
widgetId: '1', | ||
engagementId: '1', | ||
}), | ||
})); | ||
|
||
jest.mock('react-redux', () => ({ | ||
useDispatch: () => jest.fn(), | ||
})); | ||
|
||
const mockFormSubmissionData = { | ||
understand: true, | ||
termsOfReference: true, | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
city: 'New York', | ||
email: '[email protected]', | ||
}; | ||
|
||
const mockFormSubmission = { | ||
tabValue: 1, | ||
loading: false, | ||
setTabValue: jest.fn(), | ||
formSubmission: mockFormSubmissionData, | ||
setFormSubmission: jest.fn(), | ||
submitting: false, | ||
setSubmitting: jest.fn(), | ||
consentMessage: '', | ||
}; | ||
|
||
describe('FormContextProvider Component Tests', () => { | ||
const renderForm = () => { | ||
render( | ||
<Router> | ||
<FormContext.Provider value={mockFormSubmission}> | ||
<Form /> | ||
</FormContext.Provider> | ||
</Router>, | ||
); | ||
}; | ||
|
||
test('loads and displays data correctly', async () => { | ||
renderForm(); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText('Community Advisory Committee')).toBeInTheDocument(); | ||
expect(screen.getByText('Learn about and sign up for a Community Advisory Committee')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
test('loads and displays two tabs correctly', async () => { | ||
renderForm(); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText('Information')).toBeInTheDocument(); | ||
expect(screen.getByText('You and Your Community')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
test('loads and displays form fields for tabs correctly', async () => { | ||
renderForm(); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText('First Name')).toBeInTheDocument(); | ||
expect(screen.getByText('Last Name')).toBeInTheDocument(); | ||
expect(screen.getByText('City')).toBeInTheDocument(); | ||
expect(screen.getByText('Email')).toBeInTheDocument(); | ||
expect(screen.getByText('Next')).toBeInTheDocument(); | ||
expect(screen.getByText('Submit')).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.