File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
packages/x-charts/src/BarChart Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,37 @@ describe('<BarChart />', () => {
4343 expect ( screen . getByText ( 'No data to display' ) ) . toBeVisible ( ) ;
4444 } ) ;
4545
46+ it ( 'prioritizes `barLabel` from series over `barLabel` prop' , ( ) => {
47+ render (
48+ < BarChart
49+ barLabel = { ( ) => 'Bar label from prop' }
50+ series = { [ { data : [ 1 ] , barLabel : ( ) => 'Bar label from series' } ] }
51+ width = { 100 }
52+ height = { 100 }
53+ xAxis = { [ { data : [ 'A' ] } ] }
54+ yAxis = { [ ] }
55+ /> ,
56+ ) ;
57+
58+ expect ( screen . getByText ( 'Bar label from series' ) ) . toBeVisible ( ) ;
59+ } ) ;
60+
61+ it ( "defaults to `barLabel` prop when `barLabel` from series isn't defined" , ( ) => {
62+ render (
63+ < BarChart
64+ barLabel = { ( ) => 'Bar label from prop' }
65+ series = { [ { data : [ 1 ] } , { data : [ 1 ] , barLabel : ( ) => 'Bar label from 2nd series' } ] }
66+ width = { 100 }
67+ height = { 100 }
68+ xAxis = { [ { data : [ 'A' ] } ] }
69+ yAxis = { [ ] }
70+ /> ,
71+ ) ;
72+
73+ expect ( screen . getByText ( 'Bar label from prop' ) ) . toBeVisible ( ) ;
74+ expect ( screen . getByText ( 'Bar label from 2nd series' ) ) . toBeVisible ( ) ;
75+ } ) ;
76+
4677 const wrapper = ( { children } : { children ?: React . ReactNode } ) => (
4778 < div style = { { width : 400 , height : 400 } } > { children } </ div >
4879 ) ;
You can’t perform that action at this time.
0 commit comments