@@ -4,7 +4,7 @@ import React from 'react'
44import { render } from 'wrappers/testUtil'
55import type { Organization } from 'types/organization'
66import type { RepositoryCardProps } from 'types/project'
7- import RepositoriesCard from 'components/RepositoriesCard '
7+ import RepositoryCard from 'components/RepositoryCard '
88
99jest . mock ( 'next/navigation' , ( ) => ( {
1010 useRouter : jest . fn ( ) ,
@@ -40,7 +40,7 @@ jest.mock('components/InfoItem', () => {
4040const mockPush = jest . fn ( )
4141const mockUseRouter = useRouter as jest . Mock
4242
43- describe ( 'RepositoriesCard ' , ( ) => {
43+ describe ( 'RepositoryCard ' , ( ) => {
4444 beforeEach ( ( ) => {
4545 jest . clearAllMocks ( )
4646 mockUseRouter . mockReturnValue ( {
@@ -74,14 +74,14 @@ describe('RepositoriesCard', () => {
7474 } )
7575
7676 it ( 'renders without crashing with empty repositories' , ( ) => {
77- render ( < RepositoriesCard repositories = { [ ] } /> )
77+ render ( < RepositoryCard repositories = { [ ] } /> )
7878 expect ( screen . queryByTestId ( 'show-more-button' ) ) . not . toBeInTheDocument ( )
7979 } )
8080
8181 it ( 'shows first 4 repositories initially when there are more than 4' , ( ) => {
8282 const repositories = Array . from ( { length : 6 } , ( _ , i ) => createMockRepository ( i ) )
8383
84- render ( < RepositoriesCard repositories = { repositories } /> )
84+ render ( < RepositoryCard repositories = { repositories } /> )
8585
8686 expect ( screen . getByText ( 'Repository 0' ) ) . toBeInTheDocument ( )
8787 expect ( screen . getByText ( 'Repository 3' ) ) . toBeInTheDocument ( )
@@ -92,7 +92,7 @@ describe('RepositoriesCard', () => {
9292 it ( 'shows all repositories when there are 4 or fewer' , ( ) => {
9393 const repositories = Array . from ( { length : 3 } , ( _ , i ) => createMockRepository ( i ) )
9494
95- render ( < RepositoriesCard repositories = { repositories } /> )
95+ render ( < RepositoryCard repositories = { repositories } /> )
9696
9797 expect ( screen . getByText ( 'Repository 0' ) ) . toBeInTheDocument ( )
9898 expect ( screen . getByText ( 'Repository 1' ) ) . toBeInTheDocument ( )
@@ -102,23 +102,23 @@ describe('RepositoriesCard', () => {
102102 it ( 'displays ShowMoreButton when there are more than 4 repositories' , ( ) => {
103103 const repositories = Array . from ( { length : 6 } , ( _ , i ) => createMockRepository ( i ) )
104104
105- render ( < RepositoriesCard repositories = { repositories } /> )
105+ render ( < RepositoryCard repositories = { repositories } /> )
106106
107107 expect ( screen . getByTestId ( 'show-more-button' ) ) . toBeInTheDocument ( )
108108 } )
109109
110110 it ( 'does not display ShowMoreButton when there are 4 or fewer repositories' , ( ) => {
111111 const repositories = Array . from ( { length : 4 } , ( _ , i ) => createMockRepository ( i ) )
112112
113- render ( < RepositoriesCard repositories = { repositories } /> )
113+ render ( < RepositoryCard repositories = { repositories } /> )
114114
115115 expect ( screen . queryByTestId ( 'show-more-button' ) ) . not . toBeInTheDocument ( )
116116 } )
117117
118118 it ( 'toggles between showing 4 and all repositories when clicked' , ( ) => {
119119 const repositories = Array . from ( { length : 6 } , ( _ , i ) => createMockRepository ( i ) )
120120
121- render ( < RepositoriesCard repositories = { repositories } /> )
121+ render ( < RepositoryCard repositories = { repositories } /> )
122122
123123 // Initially shows first 4
124124 expect ( screen . getByText ( 'Repository 0' ) ) . toBeInTheDocument ( )
@@ -142,7 +142,7 @@ describe('RepositoriesCard', () => {
142142 it ( 'renders repository items with correct information' , ( ) => {
143143 const repositories = [ createMockRepository ( 0 ) ]
144144
145- render ( < RepositoriesCard repositories = { repositories } /> )
145+ render ( < RepositoryCard repositories = { repositories } /> )
146146
147147 expect ( screen . getByText ( 'Repository 0' ) ) . toBeInTheDocument ( )
148148 expect ( screen . getByTestId ( 'info-item-Star' ) ) . toBeInTheDocument ( )
@@ -154,7 +154,7 @@ describe('RepositoriesCard', () => {
154154 it ( 'navigates to correct URL when repository item is clicked' , ( ) => {
155155 const repositories = [ createMockRepository ( 0 ) ]
156156
157- render ( < RepositoriesCard repositories = { repositories } /> )
157+ render ( < RepositoryCard repositories = { repositories } /> )
158158
159159 const repositoryButton = screen . getByText ( 'Repository 0' )
160160 fireEvent . click ( repositoryButton )
@@ -174,7 +174,27 @@ describe('RepositoriesCard', () => {
174174 url : 'https://github.com/test/repo' ,
175175 }
176176
177- expect ( ( ) => render ( < RepositoriesCard repositories = { [ repository ] } /> ) ) . not . toThrow ( )
177+ expect ( ( ) => render ( < RepositoryCard repositories = { [ repository ] } /> ) ) . not . toThrow ( )
178+ } )
179+
180+ it ( 'repository title button has cursor-pointer class' , ( ) => {
181+ const repositories = [ createMockRepository ( 0 ) ]
182+
183+ const { container } = render ( < RepositoryCard repositories = { repositories } /> )
184+
185+ const button = container . querySelector ( 'button.cursor-pointer' )
186+ expect ( button ) . toBeInTheDocument ( )
187+ expect ( button ) . toHaveClass ( 'cursor-pointer' )
188+ } )
189+
190+ it ( 'repository title is rendered as a button element' , ( ) => {
191+ const repositories = [ createMockRepository ( 0 ) ]
192+
193+ render ( < RepositoryCard repositories = { repositories } /> )
194+
195+ const repositoryButton = screen . getByText ( 'Repository 0' ) . closest ( 'button' )
196+ expect ( repositoryButton ) . toBeInTheDocument ( )
197+ expect ( repositoryButton ?. tagName ) . toBe ( 'BUTTON' )
178198 } )
179199
180200 describe ( 'Archived Badge on Repository Cards' , ( ) => {
@@ -184,7 +204,7 @@ describe('RepositoriesCard', () => {
184204 isArchived : true ,
185205 }
186206
187- render ( < RepositoriesCard repositories = { [ archivedRepo ] } /> )
207+ render ( < RepositoryCard repositories = { [ archivedRepo ] } /> )
188208
189209 expect ( screen . getByText ( 'Archived' ) ) . toBeInTheDocument ( )
190210 } )
@@ -195,7 +215,7 @@ describe('RepositoriesCard', () => {
195215 isArchived : false ,
196216 }
197217
198- render ( < RepositoriesCard repositories = { [ activeRepo ] } /> )
218+ render ( < RepositoryCard repositories = { [ activeRepo ] } /> )
199219
200220 expect ( screen . queryByText ( 'Archived' ) ) . not . toBeInTheDocument ( )
201221 } )
@@ -205,7 +225,7 @@ describe('RepositoriesCard', () => {
205225 ...createMockRepository ( 0 ) ,
206226 }
207227
208- render ( < RepositoriesCard repositories = { [ repo ] } /> )
228+ render ( < RepositoryCard repositories = { [ repo ] } /> )
209229
210230 expect ( screen . queryByText ( 'Archived' ) ) . not . toBeInTheDocument ( )
211231 } )
@@ -218,7 +238,7 @@ describe('RepositoriesCard', () => {
218238 { ...createMockRepository ( 3 ) } ,
219239 ]
220240
221- render ( < RepositoriesCard repositories = { repositories } /> )
241+ render ( < RepositoryCard repositories = { repositories } /> )
222242
223243 const badges = screen . getAllByText ( 'Archived' )
224244 expect ( badges ) . toHaveLength ( 2 )
@@ -230,7 +250,7 @@ describe('RepositoriesCard', () => {
230250 isArchived : true ,
231251 }
232252
233- render ( < RepositoriesCard repositories = { [ archivedRepo ] } /> )
253+ render ( < RepositoryCard repositories = { [ archivedRepo ] } /> )
234254
235255 const badge = screen . getByText ( 'Archived' )
236256 expect ( badge ) . toHaveClass ( 'px-2' , 'py-1' , 'text-xs' )
@@ -242,7 +262,7 @@ describe('RepositoriesCard', () => {
242262 isArchived : true ,
243263 }
244264
245- render ( < RepositoriesCard repositories = { [ archivedRepo ] } /> )
265+ render ( < RepositoryCard repositories = { [ archivedRepo ] } /> )
246266
247267 const badge = screen . getByText ( 'Archived' )
248268 const icon = badge . querySelector ( 'svg' )
@@ -255,7 +275,7 @@ describe('RepositoriesCard', () => {
255275 isArchived : true ,
256276 }
257277
258- render ( < RepositoriesCard repositories = { [ archivedRepo ] } /> )
278+ render ( < RepositoryCard repositories = { [ archivedRepo ] } /> )
259279
260280 expect ( screen . getByText ( 'Repository 0' ) ) . toBeInTheDocument ( )
261281 expect ( screen . getByTestId ( 'info-item-Star' ) ) . toBeInTheDocument ( )
@@ -269,7 +289,7 @@ describe('RepositoriesCard', () => {
269289 isArchived : true ,
270290 }
271291
272- const { container } = render ( < RepositoriesCard repositories = { [ archivedRepo ] } /> )
292+ const { container } = render ( < RepositoryCard repositories = { [ archivedRepo ] } /> )
273293
274294 const headerContainer = container . querySelector ( '.flex.items-start.justify-between' )
275295 expect ( headerContainer ) . toBeInTheDocument ( )
@@ -281,7 +301,7 @@ describe('RepositoriesCard', () => {
281301 isArchived : null ,
282302 }
283303
284- render ( < RepositoriesCard repositories = { [ repo ] } /> )
304+ render ( < RepositoryCard repositories = { [ repo ] } /> )
285305
286306 expect ( screen . queryByText ( 'Archived' ) ) . not . toBeInTheDocument ( )
287307 } )
@@ -292,7 +312,7 @@ describe('RepositoriesCard', () => {
292312 isArchived : i % 2 === 0 ,
293313 } ) )
294314
295- render ( < RepositoriesCard repositories = { repositories } /> )
315+ render ( < RepositoryCard repositories = { repositories } /> )
296316
297317 expect ( screen . getAllByText ( 'Archived' ) ) . toHaveLength ( 2 )
298318
@@ -311,7 +331,7 @@ describe('RepositoriesCard', () => {
311331 isArchived : true ,
312332 }
313333
314- render ( < RepositoriesCard repositories = { [ archivedRepo ] } /> )
334+ render ( < RepositoryCard repositories = { [ archivedRepo ] } /> )
315335
316336 const repositoryButton = screen . getByText ( 'Repository 0' )
317337 fireEvent . click ( repositoryButton )
0 commit comments