@@ -56,14 +56,23 @@ describe("Switch", () => {
5656 expect ( screen . getByTestId ( `${ name } $label` ) ) . toBeTruthy ( ) ;
5757 } ) ;
5858
59- it ( "with showLabel true renders label horizontally " , ( ) => {
59+ it ( "with showLabel true and horizontal orientation, renders label and switch in a row " , ( ) => {
6060 const props = createProps ( {
61- showLabel : true
61+ showLabel : true ,
62+ labelOrientation : "horizontal" ,
63+ label : dynamicValue < string > ( "Test Label" , false )
6264 } ) ;
6365
6466 render ( < Switch { ...props } /> ) ;
65- const wrapper = screen . getByTestId ( `${ name } $wrapper` ) ;
66- expect ( wrapper . props . style ) . toEqual ( expect . arrayContaining ( [ { flexDirection : "row" , alignItems : "center" } ] ) ) ;
67+
68+ const horizontalContainer = screen . getByTestId ( `${ name } $horizontalContainer` ) ;
69+
70+ expect ( horizontalContainer . props . style ) . toEqual (
71+ expect . objectContaining ( { flexDirection : "row" , alignItems : "center" } )
72+ ) ;
73+
74+ expect ( horizontalContainer ) . toContainElement ( screen . getByTestId ( `${ name } $label` ) ) ;
75+ expect ( horizontalContainer ) . toContainElement ( screen . getByTestId ( name ) ) ;
6776 } ) ;
6877
6978 it ( "with showLabel true and labelOrientation vertical, renders vertical" , ( ) => {
@@ -75,8 +84,9 @@ describe("Switch", () => {
7584 render ( < Switch { ...props } /> ) ;
7685 const wrapper = screen . getByTestId ( `${ name } $wrapper` ) ;
7786 expect ( wrapper . props . style ) . toEqual (
78- expect . not . arrayContaining ( [ { flexDirection : "row " , alignItems : "center " } ] )
87+ expect . arrayContaining ( [ { flexDirection : "column " , alignItems : "flex-start " } ] )
7988 ) ;
89+ expect ( screen . queryByTestId ( `${ name } $horizontalContainer` ) ) . toBeNull ( ) ;
8090 } ) ;
8191
8292 it ( "with error renders validation message" , ( ) => {
0 commit comments