@@ -6,6 +6,20 @@ jest.mock("@/components/ui", () => ({
66 Heading : ( { children, ...props } : any ) => < h2 { ...props } > { children } </ h2 > ,
77 Text : ( { children, ...props } : any ) => < span { ...props } > { children } </ span > ,
88 Badge : ( { children, ...props } : any ) => < div { ...props } > { children } </ div > ,
9+ ContactForm : ( { formTitle, ...props } : any ) => (
10+ < div data-testid = "contact-form" { ...props } >
11+ < h3 > { formTitle } </ h3 >
12+ < form >
13+ < label htmlFor = "name" > Name</ label >
14+ < input data-testid = "name-input" id = "name" name = "name" required />
15+ < label htmlFor = "email" > Email Address</ label >
16+ < input data-testid = "email-input" id = "email" name = "email" type = "email" required />
17+ < label htmlFor = "message" > Message</ label >
18+ < textarea data-testid = "message-textarea" id = "message" name = "message" required />
19+ < button data-testid = "submit-button" type = "submit" > Send Message</ button >
20+ </ form >
21+ </ div >
22+ ) ,
923} ) ) ;
1024
1125jest . mock ( "framer-motion" , ( ) => ( {
@@ -92,44 +106,31 @@ describe("ContactSection", () => {
92106 expect ( screen . getByTestId ( "submit-button" ) ) . toHaveTextContent ( "Send Message" ) ;
93107 } ) ;
94108
95- it ( "displays form submission message when form is submitted" , async ( ) => {
109+ it ( "renders contact form with proper structure" , ( ) => {
96110 render ( < ContactSection { ...defaultProps } /> ) ;
97111
98112 const nameInput = screen . getByTestId ( "name-input" ) ;
99113 const emailInput = screen . getByTestId ( "email-input" ) ;
100114 const messageTextarea = screen . getByTestId ( "message-textarea" ) ;
101115 const form = screen . getByTestId ( "contact-form" ) . querySelector ( "form" ) ;
102116
103- fireEvent . change ( nameInput , { target : { value : "Test User" } } ) ;
104- fireEvent . change ( emailInput , { target : { value : "test@example.com" } } ) ;
105- fireEvent . change ( messageTextarea , { target : { value : "Test message" } } ) ;
106-
117+ expect ( nameInput ) . toBeInTheDocument ( ) ;
118+ expect ( emailInput ) . toBeInTheDocument ( ) ;
119+ expect ( messageTextarea ) . toBeInTheDocument ( ) ;
107120 expect ( form ) . toBeInTheDocument ( ) ;
108- fireEvent . submit ( form ! ) ;
109-
110- await waitFor ( ( ) => {
111- expect ( screen . getByText ( "Feature coming soon! This form will be available when the site goes live." ) ) . toBeInTheDocument ( ) ;
112- } ) ;
113121 } ) ;
114122
115- it ( "message disappears after timeout" , async ( ) => {
116- jest . useFakeTimers ( ) ;
117- render ( < ContactSection { ...defaultProps } /> ) ;
118-
119- const form = screen . getByTestId ( "contact-form" ) . querySelector ( "form" ) ;
120- fireEvent . submit ( form ! ) ;
121-
122- await waitFor ( ( ) => {
123- expect ( screen . getByText ( "Feature coming soon! This form will be available when the site goes live." ) ) . toBeInTheDocument ( ) ;
124- } ) ;
125-
126- jest . advanceTimersByTime ( 5000 ) ;
123+ it ( "renders with custom form title" , ( ) => {
124+ const customFormTitle = "Custom Form Title" ;
125+ render ( < ContactSection { ...defaultProps } formTitle = { customFormTitle } /> ) ;
127126
128- await waitFor ( ( ) => {
129- expect ( screen . queryByText ( "Feature coming soon! This form will be available when the site goes live." ) ) . not . toBeInTheDocument ( ) ;
130- } ) ;
127+ const contactForm = screen . getByTestId ( "contact-form" ) ;
128+ expect ( contactForm ) . toBeInTheDocument ( ) ;
131129
132- jest . useRealTimers ( ) ;
130+ // Check that the custom form title is rendered in the form
131+ const formHeading = contactForm . querySelector ( "h3" ) ;
132+ expect ( formHeading ) . toBeInTheDocument ( ) ;
133+ expect ( formHeading ) . toHaveTextContent ( customFormTitle ) ;
133134 } ) ;
134135
135136 it ( "uses custom section titles when provided" , ( ) => {
0 commit comments