@@ -47,31 +47,113 @@ describe('AnchorFm', () => {
4747 } ) ;
4848
4949 // Coverage gaps - test stubs to implement
50- it . skip ( 'should handle empty episodeUrl gracefully' , async ( ) => {
50+ it ( 'should handle empty episodeUrl gracefully' , async ( ) => {
5151 // Test edge case: empty or invalid episode URL
52+ const { getByTestId } = render ( AnchorFm , {
53+ episodeUrl : '' ,
54+ disable_observer : true ,
55+ } ) ;
56+ const iframe = getByTestId ( 'anchor-fm-episode' ) ;
57+ await expect
58+ . element ( iframe )
59+ . toHaveAttribute ( 'src' , 'https://anchor.fm/' ) ;
60+ await expect
61+ . element ( iframe )
62+ . toHaveAttribute ( 'title' , 'anchor-fm-' ) ;
5263 } ) ;
5364
54- it . skip ( 'should apply default height and width when not provided' , async ( ) => {
65+ it ( 'should apply default height and width when not provided' , async ( ) => {
5566 // Test default prop values (height: '100px', width: '100%')
67+ const { container } = render ( AnchorFm , {
68+ episodeUrl,
69+ disable_observer : true ,
70+ } ) ;
71+ const iframe = container . querySelector ( 'iframe' ) ;
72+
73+ expect ( iframe ?. parentElement ?. style . height ) . toBe ( '100px' ) ;
74+ expect ( iframe ?. parentElement ?. style . width ) . toBe ( '100%' ) ;
5675 } ) ;
5776
58- it . skip ( 'should handle special characters in episodeUrl' , async ( ) => {
77+ it ( 'should handle special characters in episodeUrl' , async ( ) => {
5978 // Test URL encoding and special characters
79+ const specialUrl =
80+ 'test-podcast/episodes/episode-with-special-chars-!@#$%^&*()' ;
81+ const { getByTestId } = render ( AnchorFm , {
82+ episodeUrl : specialUrl ,
83+ disable_observer : true ,
84+ } ) ;
85+ const iframe = getByTestId ( 'anchor-fm-episode' ) ;
86+ const expectedSrc = `https://anchor.fm/${ specialUrl } ` ;
87+ await expect . element ( iframe ) . toHaveAttribute ( 'src' , expectedSrc ) ;
88+ await expect
89+ . element ( iframe )
90+ . toHaveAttribute ( 'title' , `anchor-fm-${ specialUrl } ` ) ;
6091 } ) ;
6192
62- it . skip ( 'should have proper iframe accessibility attributes' , async ( ) => {
93+ it ( 'should have proper iframe accessibility attributes' , async ( ) => {
6394 // Test title attribute, aria-labels, etc.
95+ const { getByTestId } = render ( AnchorFm , {
96+ episodeUrl,
97+ disable_observer : true ,
98+ } ) ;
99+ const iframe = getByTestId ( 'anchor-fm-episode' ) ;
100+
101+ await expect
102+ . element ( iframe )
103+ . toHaveAttribute ( 'title' , `anchor-fm-${ episodeUrl } ` ) ;
104+ await expect . element ( iframe ) . toHaveAttribute ( 'frameborder' , '0' ) ;
105+ await expect . element ( iframe ) . toHaveAttribute ( 'scrolling' , 'no' ) ;
64106 } ) ;
65107
66- it . skip ( 'should handle very long episodeUrl values' , async ( ) => {
108+ it ( 'should handle very long episodeUrl values' , async ( ) => {
67109 // Test edge case: extremely long URLs
110+ const longUrl = 'a' . repeat ( 1000 ) + '/episodes/' + 'b' . repeat ( 500 ) ;
111+ const { getByTestId } = render ( AnchorFm , {
112+ episodeUrl : longUrl ,
113+ disable_observer : true ,
114+ } ) ;
115+ const iframe = getByTestId ( 'anchor-fm-episode' ) ;
116+ const expectedSrc = `https://anchor.fm/${ longUrl } ` ;
117+ await expect . element ( iframe ) . toHaveAttribute ( 'src' , expectedSrc ) ;
68118 } ) ;
69119
70- it . skip ( 'should apply custom CSS styles correctly' , async ( ) => {
120+ it ( 'should apply custom CSS styles correctly' , async ( ) => {
71121 // Test that custom height/width styles are properly applied
122+ const customHeight = '300px' ;
123+ const customWidth = '75%' ;
124+ const { container } = render ( AnchorFm , {
125+ episodeUrl,
126+ height : customHeight ,
127+ width : customWidth ,
128+ disable_observer : true ,
129+ } ) ;
130+ const iframe = container . querySelector ( 'iframe' ) ;
131+ const wrapperDiv = iframe ?. parentElement ;
132+
133+ expect ( wrapperDiv ?. style . height ) . toBe ( customHeight ) ;
134+ expect ( wrapperDiv ?. style . width ) . toBe ( customWidth ) ;
135+ expect ( wrapperDiv ?. style . position ) . toBe ( 'relative' ) ;
136+
137+ // Check iframe styles
138+ expect ( iframe ?. style . position ) . toBe ( 'absolute' ) ;
139+ expect ( iframe ?. style . top ) . toBe ( '0px' ) ;
140+ expect ( iframe ?. style . left ) . toBe ( '0px' ) ;
141+ expect ( iframe ?. style . width ) . toBe ( '100%' ) ;
142+ expect ( iframe ?. style . height ) . toBe ( '100%' ) ;
72143 } ) ;
73144
74- it . skip ( 'should handle numeric height and width values' , async ( ) => {
145+ it ( 'should handle numeric height and width values' , async ( ) => {
75146 // Test passing numbers instead of strings for dimensions
147+ const { container } = render ( AnchorFm , {
148+ episodeUrl,
149+ height : '250px' ,
150+ width : '80%' ,
151+ disable_observer : true ,
152+ } ) ;
153+ const iframe = container . querySelector ( 'iframe' ) ;
154+
155+ // Component should handle numeric values by converting them
156+ expect ( iframe ?. parentElement ?. style . height ) . toBe ( '250px' ) ;
157+ expect ( iframe ?. parentElement ?. style . width ) . toBe ( '80%' ) ;
76158 } ) ;
77159} ) ;
0 commit comments