11import { render , screen , waitFor } from '@testing-library/react' ;
2- import { getWrapper } from '../../testUtils' ;
3- import { Barchart , CustomTick } from './Barchart.component ' ;
4- import { ChartLegendWrapper } from '../chartlegend /ChartLegendWrapper' ;
2+ import { getWrapper } from '../../../ testUtils' ;
3+ import { Barchart } from './Barchart' ;
4+ import { ChartLegendWrapper } from '../legend /ChartLegendWrapper' ;
55import React from 'react' ;
6+ import { CustomTick } from '../common/SharedComponents' ;
67
78const ONE_DAY_IN_MILLISECONDS = 24 * 60 * 60 * 1000 ;
89const ONE_HOUR_IN_MILLISECONDS = 60 * 60 * 1000 ;
@@ -60,21 +61,27 @@ describe('Barchart', () => {
6061 render (
6162 < Wrapper >
6263 < ChartLegendWrapper colorSet = { testColorSet } >
63- < Barchart type = { { type : 'category' } } bars = { testBars } />
64+ < Barchart
65+ title = "Test Title"
66+ type = { { type : 'category' } }
67+ bars = { testBars }
68+ />
6469 </ ChartLegendWrapper >
6570 </ Wrapper > ,
6671 ) ;
67-
72+ expect ( screen . getByText ( 'Test Title' ) ) . toBeInTheDocument ( ) ;
6873 expect ( screen . getByText ( 'category1' ) ) . toBeInTheDocument ( ) ;
6974 expect ( screen . getByText ( 'category2' ) ) . toBeInTheDocument ( ) ;
7075 expect ( screen . getByText ( 'category3' ) ) . toBeInTheDocument ( ) ;
7176 } ) ;
77+
7278 it ( 'should render the Barchart component with time data' , async ( ) => {
7379 const { Wrapper } = getWrapper ( ) ;
7480 render (
7581 < Wrapper >
7682 < ChartLegendWrapper colorSet = { testColorSet } >
7783 < Barchart
84+ title = "Test Title"
7885 type = { {
7986 type : 'time' ,
8087 timeRange : {
@@ -98,7 +105,12 @@ describe('Barchart', () => {
98105 render (
99106 < Wrapper >
100107 < ChartLegendWrapper colorSet = { testColorSet } >
101- < Barchart type = { { type : 'category' } } bars = { [ ] } isError />
108+ < Barchart
109+ title = "Test Title"
110+ type = { { type : 'category' } }
111+ bars = { [ ] }
112+ isError
113+ />
102114 </ ChartLegendWrapper >
103115 </ Wrapper > ,
104116 ) ;
@@ -111,7 +123,12 @@ describe('Barchart', () => {
111123 render (
112124 < Wrapper >
113125 < ChartLegendWrapper colorSet = { testColorSet } >
114- < Barchart type = { { type : 'category' } } bars = { [ ] } isLoading />
126+ < Barchart
127+ title = "Test Title"
128+ type = { { type : 'category' } }
129+ bars = { [ ] }
130+ isLoading
131+ />
115132 </ ChartLegendWrapper >
116133 </ Wrapper > ,
117134 ) ;
@@ -122,7 +139,11 @@ describe('Barchart', () => {
122139 render (
123140 < Wrapper >
124141 < ChartLegendWrapper colorSet = { testColorSet } >
125- < Barchart type = { { type : 'category' } } bars = { undefined } />
142+ < Barchart
143+ title = "Test Title"
144+ type = { { type : 'category' } }
145+ bars = { undefined }
146+ />
126147 </ ChartLegendWrapper >
127148 </ Wrapper > ,
128149 ) ;
@@ -139,6 +160,7 @@ describe('Barchart', () => {
139160 < Wrapper >
140161 < ChartLegendWrapper colorSet = { testColorSet } >
141162 < Barchart
163+ title = "Test Title"
142164 type = { {
143165 type : 'time' ,
144166 timeRange : {
@@ -196,7 +218,7 @@ describe('Barchart', () => {
196218 Failed : 'lineColor2' ,
197219 } }
198220 >
199- < Barchart type = { type } bars = { bars } />
221+ < Barchart title = "Test Title" type = { type } bars = { bars } />
200222 </ ChartLegendWrapper >
201223 </ Wrapper > ,
202224 ) ;
@@ -239,7 +261,7 @@ describe('Barchart', () => {
239261 render (
240262 < Wrapper >
241263 < ChartLegendWrapper colorSet = { testColorSet } >
242- < Barchart type = { type } bars = { testTimeBars } />
264+ < Barchart title = "Test Title" type = { type } bars = { testTimeBars } />
243265 </ ChartLegendWrapper >
244266 </ Wrapper > ,
245267 ) ;
@@ -270,6 +292,7 @@ describe('Barchart', () => {
270292 < Wrapper >
271293 < ChartLegendWrapper colorSet = { testColorSet } >
272294 < Barchart
295+ title = "Test Title"
273296 type = { {
274297 type : 'time' ,
275298 timeRange : {
@@ -317,6 +340,7 @@ describe('Barchart', () => {
317340 < Wrapper >
318341 < ChartLegendWrapper colorSet = { { ...testColorSet , Failed : 'red' } } >
319342 < Barchart
343+ title = "Test Title"
320344 type = { { type : 'category' } }
321345 bars = { testStackedBars }
322346 stacked
@@ -348,6 +372,7 @@ describe('Barchart', () => {
348372 < Wrapper >
349373 < ChartLegendWrapper colorSet = { testColorSet } >
350374 < Barchart
375+ title = "Test Title"
351376 type = { { type : 'category' } }
352377 bars = { testBars }
353378 defaultSort = { ( pointA , pointB ) => {
0 commit comments