@@ -16,25 +16,57 @@ describe('<Divider />', () => {
1616 it ( 'should render horizontal type by default' , ( ) => {
1717 const { container } = render ( < Divider /> ) ;
1818 expect ( container . firstChild ) . toHaveClass ( 'ty-divider_horizontal' ) ;
19+ expect ( container . firstChild ) . toHaveClass ( 'ty-divider_solid' ) ;
20+ expect ( container . firstChild ) . toHaveAttribute ( 'aria-orientation' , 'horizontal' ) ;
1921 } ) ;
2022
21- it ( 'should render vertical type ' , ( ) => {
22- const { container } = render ( < Divider type = "vertical" /> ) ;
23+ it ( 'should render vertical orientation ' , ( ) => {
24+ const { container } = render ( < Divider orientation = "vertical" /> ) ;
2325 expect ( container . firstChild ) . toHaveClass ( 'ty-divider_vertical' ) ;
26+ expect ( container . firstChild ) . toHaveAttribute ( 'aria-orientation' , 'vertical' ) ;
2427 } ) ;
2528
26- it ( 'should render dashed style' , ( ) => {
27- const { container } = render ( < Divider dashed /> ) ;
28- expect ( container . firstChild ) . toHaveClass ( 'ty-divider_horizontal-dashed ' ) ;
29+ it ( 'should render variant style' , ( ) => {
30+ const { container } = render ( < Divider variant = " dashed" /> ) ;
31+ expect ( container . firstChild ) . toHaveClass ( 'ty-divider_dashed ' ) ;
2932 } ) ;
3033
3134 it ( 'should render with text' , ( ) => {
3235 const { getByText } = render ( < Divider > Section</ Divider > ) ;
3336 expect ( getByText ( 'Section' ) ) . toBeInTheDocument ( ) ;
3437 } ) ;
3538
36- it ( 'should render text with alignment' , ( ) => {
37- const { container } = render ( < Divider align = "left" > Left</ Divider > ) ;
39+ it ( 'should render text with title placement' , ( ) => {
40+ const { container } = render ( < Divider titlePlacement = "start" > Left</ Divider > ) ;
41+ expect ( container . firstChild ) . toHaveClass ( 'ty-divider_start' ) ;
42+ expect ( container . firstChild ) . toHaveClass ( 'ty-divider_text' ) ;
3843 expect ( container . querySelector ( '.ty-divider_inner-text' ) ) . toBeInTheDocument ( ) ;
3944 } ) ;
45+
46+ it ( 'should render falsy children content' , ( ) => {
47+ const { container, getByText } = render ( < Divider > { 0 } </ Divider > ) ;
48+ expect ( container . firstChild ) . toHaveClass ( 'ty-divider_text' ) ;
49+ expect ( getByText ( '0' ) ) . toBeInTheDocument ( ) ;
50+ } ) ;
51+
52+ it ( 'should render plain style' , ( ) => {
53+ const { container } = render ( < Divider plain > Plain</ Divider > ) ;
54+ expect ( container . firstChild ) . toHaveClass ( 'ty-divider_plain' ) ;
55+ } ) ;
56+
57+ it ( 'should apply title gap custom property' , ( ) => {
58+ const { container } = render ( < Divider titleGap = { 24 } > Gap</ Divider > ) ;
59+ expect ( container . firstChild ) . toHaveStyle ( '--ty-divider-title-gap: 24px' ) ;
60+ } ) ;
61+
62+ it ( 'should not render inner text for vertical divider' , ( ) => {
63+ const { container, queryByText } = render (
64+ < Divider orientation = "vertical" titlePlacement = "start" >
65+ Hidden
66+ </ Divider > ,
67+ ) ;
68+ expect ( container . firstChild ) . not . toHaveClass ( 'ty-divider_text' ) ;
69+ expect ( container . firstChild ) . not . toHaveClass ( 'ty-divider_start' ) ;
70+ expect ( queryByText ( 'Hidden' ) ) . not . toBeInTheDocument ( ) ;
71+ } ) ;
4072} ) ;
0 commit comments