1- import { faArchive } from '@fortawesome/free-solid-svg-icons'
21import { render , screen } from '@testing-library/react'
3- import React from 'react'
42import ArchivedBadge from 'components/ArchivedBadge'
53
64jest . mock ( '@fortawesome/react-fontawesome' , ( ) => ( {
7- FontAwesomeIcon : ( { icon , className } : { icon : any ; className : string } ) => (
5+ FontAwesomeIcon : ( { className } : { className : string } ) => (
86 < i data-testid = "archive-icon" className = { className } />
97 ) ,
108} ) )
@@ -13,53 +11,50 @@ describe('ArchivedBadge', () => {
1311 describe ( 'Basic Rendering' , ( ) => {
1412 it ( 'renders successfully with default props' , ( ) => {
1513 render ( < ArchivedBadge /> )
16-
14+
1715 expect ( screen . getByText ( 'Archived' ) ) . toBeInTheDocument ( )
1816 } )
1917
2018 it ( 'displays the archived text' , ( ) => {
2119 render ( < ArchivedBadge /> )
22-
20+
2321 const badge = screen . getByText ( 'Archived' )
2422 expect ( badge ) . toBeVisible ( )
2523 } )
2624
2725 it ( 'has the correct tooltip' , ( ) => {
2826 render ( < ArchivedBadge /> )
29-
27+
3028 const badge = screen . getByText ( 'Archived' )
31- expect ( badge ) . toHaveAttribute (
32- 'title' ,
33- 'This repository has been archived and is read-only'
34- )
29+ expect ( badge ) . toHaveAttribute ( 'title' , 'This repository has been archived and is read-only' )
3530 } )
3631 } )
3732
3833 describe ( 'Size Variants' , ( ) => {
3934 it ( 'renders with small size' , ( ) => {
4035 render ( < ArchivedBadge size = "sm" /> )
41-
36+
4237 const badge = screen . getByText ( 'Archived' )
4338 expect ( badge ) . toHaveClass ( 'px-2' , 'py-1' , 'text-xs' )
4439 } )
4540
4641 it ( 'renders with medium size (default)' , ( ) => {
4742 render ( < ArchivedBadge size = "md" /> )
48-
43+
4944 const badge = screen . getByText ( 'Archived' )
5045 expect ( badge ) . toHaveClass ( 'px-3' , 'py-1' , 'text-sm' )
5146 } )
5247
5348 it ( 'renders with large size' , ( ) => {
5449 render ( < ArchivedBadge size = "lg" /> )
55-
50+
5651 const badge = screen . getByText ( 'Archived' )
5752 expect ( badge ) . toHaveClass ( 'px-4' , 'py-2' , 'text-base' )
5853 } )
5954
6055 it ( 'defaults to medium size when size prop is not provided' , ( ) => {
6156 render ( < ArchivedBadge /> )
62-
57+
6358 const badge = screen . getByText ( 'Archived' )
6459 expect ( badge ) . toHaveClass ( 'px-3' , 'py-1' , 'text-sm' )
6560 } )
@@ -68,28 +63,28 @@ describe('ArchivedBadge', () => {
6863 describe ( 'Icon Display' , ( ) => {
6964 it ( 'shows icon by default' , ( ) => {
7065 render ( < ArchivedBadge /> )
71-
66+
7267 const icon = screen . getByTestId ( 'archive-icon' )
7368 expect ( icon ) . toBeInTheDocument ( )
7469 } )
7570
7671 it ( 'shows icon when showIcon is true' , ( ) => {
7772 render ( < ArchivedBadge showIcon = { true } /> )
78-
73+
7974 const icon = screen . getByTestId ( 'archive-icon' )
8075 expect ( icon ) . toBeInTheDocument ( )
8176 } )
8277
8378 it ( 'hides icon when showIcon is false' , ( ) => {
8479 render ( < ArchivedBadge showIcon = { false } /> )
85-
80+
8681 const icon = screen . queryByTestId ( 'archive-icon' )
8782 expect ( icon ) . not . toBeInTheDocument ( )
8883 } )
8984
9085 it ( 'applies correct icon class' , ( ) => {
9186 render ( < ArchivedBadge /> )
92-
87+
9388 const icon = screen . getByTestId ( 'archive-icon' )
9489 expect ( icon ) . toHaveClass ( 'h-3' , 'w-3' )
9590 } )
@@ -98,31 +93,21 @@ describe('ArchivedBadge', () => {
9893 describe ( 'Styling' , ( ) => {
9994 it ( 'has correct base styling classes' , ( ) => {
10095 render ( < ArchivedBadge /> )
101-
96+
10297 const badge = screen . getByText ( 'Archived' )
103- expect ( badge ) . toHaveClass (
104- 'inline-flex' ,
105- 'items-center' ,
106- 'gap-1.5' ,
107- 'rounded-full' ,
108- 'border'
109- )
98+ expect ( badge ) . toHaveClass ( 'inline-flex' , 'items-center' , 'gap-1.5' , 'rounded-full' , 'border' )
11099 } )
111100
112101 it ( 'has correct light mode color classes' , ( ) => {
113102 render ( < ArchivedBadge /> )
114-
103+
115104 const badge = screen . getByText ( 'Archived' )
116- expect ( badge ) . toHaveClass (
117- 'border-yellow-600' ,
118- 'bg-yellow-50' ,
119- 'text-yellow-800'
120- )
105+ expect ( badge ) . toHaveClass ( 'border-yellow-600' , 'bg-yellow-50' , 'text-yellow-800' )
121106 } )
122107
123108 it ( 'has correct dark mode color classes' , ( ) => {
124109 render ( < ArchivedBadge /> )
125-
110+
126111 const badge = screen . getByText ( 'Archived' )
127112 expect ( badge ) . toHaveClass (
128113 'dark:border-yellow-500' ,
@@ -133,7 +118,7 @@ describe('ArchivedBadge', () => {
133118
134119 it ( 'has font-medium class' , ( ) => {
135120 render ( < ArchivedBadge /> )
136-
121+
137122 const badge = screen . getByText ( 'Archived' )
138123 expect ( badge ) . toHaveClass ( 'font-medium' )
139124 } )
@@ -142,21 +127,21 @@ describe('ArchivedBadge', () => {
142127 describe ( 'Custom ClassName' , ( ) => {
143128 it ( 'applies custom className' , ( ) => {
144129 render ( < ArchivedBadge className = "custom-class" /> )
145-
130+
146131 const badge = screen . getByText ( 'Archived' )
147132 expect ( badge ) . toHaveClass ( 'custom-class' )
148133 } )
149134
150135 it ( 'preserves default classes with custom className' , ( ) => {
151136 render ( < ArchivedBadge className = "ml-2" /> )
152-
137+
153138 const badge = screen . getByText ( 'Archived' )
154139 expect ( badge ) . toHaveClass ( 'ml-2' , 'inline-flex' , 'rounded-full' )
155140 } )
156141
157142 it ( 'handles empty custom className' , ( ) => {
158143 render ( < ArchivedBadge className = "" /> )
159-
144+
160145 const badge = screen . getByText ( 'Archived' )
161146 expect ( badge ) . toBeInTheDocument ( )
162147 } )
@@ -165,14 +150,14 @@ describe('ArchivedBadge', () => {
165150 describe ( 'Accessibility' , ( ) => {
166151 it ( 'renders as a span element' , ( ) => {
167152 render ( < ArchivedBadge /> )
168-
153+
169154 const badge = screen . getByText ( 'Archived' )
170155 expect ( badge . tagName ) . toBe ( 'SPAN' )
171156 } )
172157
173158 it ( 'has descriptive tooltip for screen readers' , ( ) => {
174159 render ( < ArchivedBadge /> )
175-
160+
176161 const badge = screen . getByText ( 'Archived' )
177162 const title = badge . getAttribute ( 'title' )
178163 expect ( title ) . toBeTruthy ( )
@@ -182,22 +167,16 @@ describe('ArchivedBadge', () => {
182167
183168 it ( 'has appropriate semantic structure with icon' , ( ) => {
184169 render ( < ArchivedBadge /> )
185-
170+
186171 const badge = screen . getByText ( 'Archived' )
187172 expect ( badge ) . toContainHTML ( 'i' )
188173 } )
189174 } )
190175
191176 describe ( 'Edge Cases' , ( ) => {
192177 it ( 'handles all props together' , ( ) => {
193- render (
194- < ArchivedBadge
195- size = "lg"
196- showIcon = { false }
197- className = "extra-margin"
198- />
199- )
200-
178+ render ( < ArchivedBadge size = "lg" showIcon = { false } className = "extra-margin" /> )
179+
201180 const badge = screen . getByText ( 'Archived' )
202181 expect ( badge ) . toBeInTheDocument ( )
203182 expect ( badge ) . toHaveClass ( 'px-4' , 'py-2' , 'text-base' , 'extra-margin' )
@@ -206,18 +185,18 @@ describe('ArchivedBadge', () => {
206185
207186 it ( 'renders consistently across multiple instances' , ( ) => {
208187 const { rerender } = render ( < ArchivedBadge /> )
209-
188+
210189 const firstRender = screen . getByText ( 'Archived' ) . className
211-
190+
212191 rerender ( < ArchivedBadge /> )
213-
192+
214193 const secondRender = screen . getByText ( 'Archived' ) . className
215194 expect ( firstRender ) . toBe ( secondRender )
216195 } )
217196
218197 it ( 'does not render any interactive elements' , ( ) => {
219198 const { container } = render ( < ArchivedBadge /> )
220-
199+
221200 expect ( container . querySelector ( 'button' ) ) . not . toBeInTheDocument ( )
222201 expect ( container . querySelector ( 'a' ) ) . not . toBeInTheDocument ( )
223202 expect ( container . querySelector ( 'input' ) ) . not . toBeInTheDocument ( )
0 commit comments