File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -70,4 +70,27 @@ describe('PowerSummaryTable Component', () => {
7070 expect ( within ( noMessageRow ) . queryByText ( 'Warning message' ) ) . toBeNull ( ) ;
7171 expect ( within ( noMessageRow ) . queryByText ( 'Error message' ) ) . toBeNull ( ) ;
7272 } ) ;
73+
74+ test ( 'total and percent values match sum of data' , ( ) => {
75+ render ( < PowerSummaryTable title = "Power Summary" data = { mockData } total = { 60 } percent = { 80 } /> ) ;
76+
77+ const displayedTotal = screen . getByText ( ( content ) => content . includes ( '60.00' ) && content . includes ( 'W' ) ) ;
78+ expect ( displayedTotal ) . toBeInTheDocument ( ) ;
79+
80+ const progressBar = screen . getByRole ( 'progressbar' ) ;
81+ expect ( progressBar ) . toHaveAttribute ( 'value' , '80' ) ;
82+ expect ( progressBar ) . toHaveAttribute ( 'max' , '100' ) ;
83+ } ) ;
84+
85+ test ( 'renders correctly with no data entries' , ( ) => {
86+ render ( < PowerSummaryTable title = "Power Summary" data = { [ ] } total = { 0 } percent = { 0 } /> ) ;
87+
88+ expect ( screen . getByText ( 'Power Summary' ) ) . toBeInTheDocument ( ) ;
89+
90+ expect ( screen . getByText ( '0.00 W' ) ) . toBeInTheDocument ( ) ;
91+ expect ( screen . getByText ( '0 %' ) ) . toBeInTheDocument ( ) ;
92+
93+ const progressBar = screen . getByRole ( 'progressbar' ) ;
94+ expect ( progressBar ) . toHaveAttribute ( 'value' , '0' ) ;
95+ } ) ;
7396} ) ;
You can’t perform that action at this time.
0 commit comments