11import React from 'react' ;
2- import { describe , it , expect } from 'vitest' ;
2+
3+ import { describe , it , expect , vi } from 'vitest' ;
34import { render , screen } from '@testing-library/react' ;
5+
46import '@testing-library/jest-dom' ;
57
6- import { ExpandIcon } from '../../src/components/icons' ;
8+ import { ExpandIcon } from '../../src/components/icons/ExpandIcon ' ;
79import type { ThemeProps } from '../../src/types/theme' ;
810
9- describe ( 'ExpandIcon' , ( ) => {
10- const mockTheme : ThemeProps = {
11- expandIcon : {
12- color : '#000000' ,
13- } ,
14- } ;
11+ const mockTheme : ThemeProps = {
12+ colors : {
13+ primaryColor : '#5D5FEF' ,
14+ textColor : '#262626' ,
15+ borderColor : '#E5E5E5' ,
16+ } ,
17+ expandIcon : {
18+ color : '#000000' ,
19+ } ,
20+ } ;
1521
16- it ( 'renders expanded icon when isExpanded is true' , ( ) => {
22+ describe ( 'ExpandIcon' , ( ) => {
23+ it ( 'applies correct transform for expanded state' , ( ) => {
1724 render ( < ExpandIcon isExpanded theme = { mockTheme } mode = "expand" /> ) ;
18- const icon = screen . getByRole ( 'img' , { hidden : true } ) ;
19- expect ( icon ) . toBeInTheDocument ( ) ;
20- expect ( icon . closest ( '.expand-icon' ) ) . toHaveClass ( 'expand-icon' ) ;
25+
26+ const expandIcon = document . querySelector ( '.expand-icon' ) ;
27+ expect ( expandIcon ) . toHaveStyle ( { transform : 'rotate(90deg)' } ) ;
2128 } ) ;
2229
23- it ( 'renders collapsed icon when isExpanded is false ' , ( ) => {
30+ it ( 'applies correct transform for collapsed state ' , ( ) => {
2431 render ( < ExpandIcon isExpanded = { false } theme = { mockTheme } mode = "expand" /> ) ;
32+
33+ const expandIcon = document . querySelector ( '.expand-icon' ) ;
34+ expect ( expandIcon ) . toHaveStyle ( { transform : 'rotate(0deg)' } ) ;
35+ } ) ;
36+
37+ it ( 'renders SVG element' , ( ) => {
38+ render ( < ExpandIcon isExpanded theme = { mockTheme } mode = "expand" /> ) ;
39+
40+ const svg = document . querySelector ( 'svg' ) ;
41+ expect ( svg ) . toBeInTheDocument ( ) ;
42+ expect ( svg ) . toHaveAttribute ( 'viewBox' , '0 0 24 24' ) ;
43+ } ) ;
2544
26- const icon = screen . getByRole ( 'img' , { hidden : true } ) ;
27- expect ( icon ) . toBeInTheDocument ( ) ;
28- expect ( icon . closest ( '.expand-icon' ) ) . toHaveClass ( 'expand-icon' ) ;
45+ it ( 'renders expand icon with SVG' , ( ) => {
46+ render ( < ExpandIcon isExpanded theme = { mockTheme } mode = "expand" /> ) ;
47+
48+ const svg = document . querySelector ( 'svg' ) ;
49+ expect ( svg ) . toBeInTheDocument ( ) ;
50+ expect ( svg ) . toHaveAttribute ( 'width' , '24' ) ;
51+ expect ( svg ) . toHaveAttribute ( 'height' , '24' ) ;
52+ } ) ;
53+
54+ it ( 'renders collapsed icon with SVG' , ( ) => {
55+ render ( < ExpandIcon isExpanded = { false } theme = { mockTheme } mode = "expand" /> ) ;
56+
57+ const svg = document . querySelector ( 'svg' ) ;
58+ expect ( svg ) . toBeInTheDocument ( ) ;
59+ expect ( svg ) . toHaveAttribute ( 'width' , '24' ) ;
60+ expect ( svg ) . toHaveAttribute ( 'height' , '24' ) ;
2961 } ) ;
3062
3163 it ( 'applies custom theme color when provided' , ( ) => {
3264 const customTheme : ThemeProps = {
65+ ...mockTheme ,
3366 expandIcon : {
3467 color : '#FF0000' ,
3568 } ,
3669 } ;
3770
3871 render ( < ExpandIcon isExpanded theme = { customTheme } mode = "expand" /> ) ;
39-
40- const icon = screen . getByRole ( 'img' , { hidden : true } ) ;
41- expect ( icon ) . toBeInTheDocument ( ) ;
72+
73+ const svg = document . querySelector ( 'svg' ) ;
74+ expect ( svg ) . toBeInTheDocument ( ) ;
75+ expect ( svg ) . toHaveAttribute ( 'width' , '24' ) ;
76+ expect ( svg ) . toHaveAttribute ( 'height' , '24' ) ;
4277 } ) ;
4378
4479 it ( 'renders without theme color when not provided' , ( ) => {
45- const themeWithoutColor : ThemeProps = { } ;
80+ const themeWithoutColor : ThemeProps = {
81+ colors : {
82+ primaryColor : '#5D5FEF' ,
83+ textColor : '#262626' ,
84+ borderColor : '#E5E5E5' ,
85+ } ,
86+ } ;
4687
4788 render ( < ExpandIcon isExpanded theme = { themeWithoutColor } mode = "expand" /> ) ;
48-
49- const icon = screen . getByRole ( 'img' , { hidden : true } ) ;
50- expect ( icon ) . toBeInTheDocument ( ) ;
89+
90+ const svg = document . querySelector ( 'svg' ) ;
91+ expect ( svg ) . toBeInTheDocument ( ) ;
92+ expect ( svg ) . toHaveAttribute ( 'width' , '24' ) ;
93+ expect ( svg ) . toHaveAttribute ( 'height' , '24' ) ;
5194 } ) ;
5295} ) ;
0 commit comments