11import { render , screen } from '@testing-library/react' ;
2+ import '@testing-library/jest-dom/vitest' ;
23import { describe , expect , it , vi } from 'vitest' ;
34import { HeroSection } from './HeroSection' ;
45
@@ -12,39 +13,51 @@ vi.mock('framer-motion', () => ({
1213} ) ) ;
1314
1415describe ( 'HeroSection' , ( ) => {
15- it ( 'renders the h1 heading' , ( ) => {
16+ it ( 'renders the hero heading and content ' , ( ) => {
1617 render ( < HeroSection /> ) ;
1718
18- const heading = screen . getByRole ( 'heading' , {
19- level : 1 ,
20- } ) ;
21-
22- expect ( heading ) . toBeDefined ( ) ;
23- } ) ;
24-
25- it ( "heading contains 'Elevate Your'" , ( ) => {
26- render ( < HeroSection /> ) ;
27-
28- expect ( screen . getByText ( / E l e v a t e Y o u r / i) ) . toBeDefined ( ) ;
29- } ) ;
30-
31- it ( "heading contains 'Contribution Story'" , ( ) => {
32- render ( < HeroSection /> ) ;
33-
34- expect ( screen . getByText ( / C o n t r i b u t i o n S t o r y / i) ) . toBeDefined ( ) ;
19+ expect (
20+ screen . getByRole ( 'heading' , {
21+ level : 1 ,
22+ name : / e l e v a t e y o u r c o n t r i b u t i o n s t o r y / i,
23+ } )
24+ ) . toBeInTheDocument ( ) ;
25+ expect ( screen . getByText ( / i s o m e t r i c / i) . textContent ) . toMatch ( / i s o m e t r i c / i) ;
3526 } ) ;
27+ } ) ;
3628
37- it ( 'renders the descriptive paragraph' , ( ) => {
38- render ( < HeroSection /> ) ;
29+ describe ( 'HeroSection responsive breakpoints' , ( ) => {
30+ const renderAtViewport = ( width : number ) => {
31+ window . innerWidth = width ;
32+ window . dispatchEvent ( new Event ( 'resize' ) ) ;
3933
40- const paragraph = screen . getByText ( / i s o m e t r i c / i) ;
34+ return render ( < HeroSection /> ) ;
35+ } ;
4136
42- expect ( paragraph ) . toBeDefined ( ) ;
43- } ) ;
37+ it . each ( [
38+ { width : 375 , label : 'mobile' } ,
39+ { width : 768 , label : 'tablet' } ,
40+ { width : 1280 , label : 'desktop' } ,
41+ ] ) ( 'renders full typography and high contrast background values at $label width' , ( { width } ) => {
42+ const { container } = renderAtViewport ( width ) ;
4443
45- it ( "paragraph mentions 'isometric'" , ( ) => {
46- render ( < HeroSection /> ) ;
44+ const hero = container . firstElementChild ;
45+ const heading = screen . getByRole ( 'heading' , {
46+ level : 1 ,
47+ name : / e l e v a t e y o u r c o n t r i b u t i o n s t o r y / i,
48+ } ) ;
4749
48- expect ( screen . getByText ( / i s o m e t r i c / i) . textContent ) . toMatch ( / i s o m e t r i c / i) ;
50+ expect ( hero ?. className ) . toContain ( 'bg-[radial-gradient' ) ;
51+ expect ( heading . tagName ) . toBe ( 'H1' ) ;
52+ expect ( heading . className ) . toContain ( 'text-5xl' ) ;
53+ expect ( heading . className ) . toContain ( 'md:text-8xl' ) ;
54+ expect ( heading . className ) . toContain ( 'from-green-500' ) ;
55+ expect ( heading . className ) . toContain ( 'to-purple-600' ) ;
56+ expect ( screen . getByText ( / g e n e r a t e h i g h - f i d e l i t y , 3 d i s o m e t r i c m o n o l i t h s / i) . className ) . toContain (
57+ 'text-gray-600'
58+ ) ;
59+ expect ( screen . getByPlaceholderText ( / e n t e r g i t h u b u s e r n a m e / i) ) . toBeInTheDocument ( ) ;
60+ expect ( screen . getByRole ( 'button' , { name : / c o p y l i n k / i } ) ) . toBeInTheDocument ( ) ;
61+ expect ( screen . getByRole ( 'button' , { name : / w a t c h d a s h b o a r d / i } ) ) . toBeInTheDocument ( ) ;
4962 } ) ;
5063} ) ;
0 commit comments