@@ -4,6 +4,9 @@ import { StepContext } from "../../context/StepContext";
44import '@testing-library/jest-dom' ;
55import Step from "./Step" ;
66import { MemoryRouter } from "react-router" ;
7+ import ContactDetails from "../ContactDetails/ContactDetails" ;
8+ import InvestmentPlans from "../InvestmentPlans/InvestmentPlans" ;
9+ import InvestmentPreferences from "../InvestmentPreferences/InvestmentPreferences" ;
710
811describe ( "Step test" , ( ) => {
912
@@ -12,45 +15,37 @@ describe("Step test", () => {
1215 * @param {Context } step
1316 * @returns The render of the Step component with the usage of the context value
1417 */
15- function renderStep ( step ) {
16- let path = "/" ;
17- if ( step === 2 ) {
18- path = "/step2" ;
19- } else if ( step === 3 ) {
20- path = "/step3" ;
21- }
18+ function renderStep ( step , component ) {
2219
2320 return render (
2421 < StepContext . Provider value = { [ step ] } >
25- < MemoryRouter initialEntries = { [ path ] } >
26- < Step />
27- </ MemoryRouter >
22+ < Step > { component } </ Step >
2823 </ StepContext . Provider >
2924 ) ;
3025 }
3126
3227 afterEach ( cleanup ) ;
3328
3429 it ( "should render the step" , ( ) => {
35- renderStep ( 1 ) ;
30+ renderStep ( 1 , < ContactDetails /> ) ;
3631
3732 expect ( screen . getByTestId ( "step" ) ) . toBeInTheDocument ( ) ;
3833 } ) ;
3934
4035 it ( "should render the contact component in the first step" , ( ) => {
41- renderStep ( 1 ) ;
36+ renderStep ( 1 , < ContactDetails /> ) ;
4237
4338 expect ( screen . getByTestId ( "contact" ) ) . toBeInTheDocument ( ) ;
4439 } ) ;
4540
4641 it ( "should render the investment plans component in the second step" , ( ) => {
47- renderStep ( 2 ) ;
42+ renderStep ( 2 , < InvestmentPlans /> ) ;
4843
4944 expect ( screen . getByTestId ( "investment-plans" ) ) . toBeInTheDocument ( ) ;
5045 } ) ;
5146
5247 it ( "should render the investment preferences component in the third step" , ( ) => {
53- renderStep ( 3 ) ;
48+ renderStep ( 3 , < InvestmentPreferences /> ) ;
5449
5550 expect ( screen . getByTestId ( "investment-preferences" ) ) . toBeInTheDocument ( ) ;
5651 } ) ;
0 commit comments