diff --git a/packages/bpk-component-barchart/src/BpkBarchart-test.js b/packages/bpk-component-barchart/src/BpkBarchart-test.js index 4a6f36a941..fd2f6034e5 100644 --- a/packages/bpk-component-barchart/src/BpkBarchart-test.js +++ b/packages/bpk-component-barchart/src/BpkBarchart-test.js @@ -44,6 +44,22 @@ describe('BpkBarchart', () => { expect(asFragment()).toMatchSnapshot(); }); + it('should render correctly with "className" prop', () => { + const { asFragment } = render( + , + ); + expect(asFragment()).toMatchSnapshot(); + }); + it('should render correctly with "leadingScrollIndicatorClassName" prop', () => { const { asFragment } = render( { svgEl: ?Element; static defaultProps = { + className: null, leadingScrollIndicatorClassName: null, trailingScrollIndicatorClassName: null, outlierPercentage: null, @@ -168,6 +170,7 @@ class BpkBarchart extends Component { render() { const { BarComponent, + className, data, disableDataTable, getBarLabel, @@ -204,6 +207,11 @@ class BpkBarchart extends Component { bottom: xAxisMargin, }); + const classNames = [getClassName('bpk-barchart')]; + if (className) { + classNames.push(className); + } + const width = this.state.width - margin.left - margin.right; const height = this.state.height - margin.bottom - margin.top; const maxYValue = getMaxYValue( @@ -233,7 +241,7 @@ class BpkBarchart extends Component { {/* $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'. */} { @@ -322,6 +330,7 @@ BpkBarchart.propTypes = { initialWidth: PropTypes.number.isRequired, initialHeight: PropTypes.number.isRequired, + className: PropTypes.string, leadingScrollIndicatorClassName: PropTypes.string, trailingScrollIndicatorClassName: PropTypes.string, /** diff --git a/packages/bpk-component-barchart/src/__snapshots__/BpkBarchart-test.js.snap b/packages/bpk-component-barchart/src/__snapshots__/BpkBarchart-test.js.snap index a8a59fba90..a3dc705efc 100644 --- a/packages/bpk-component-barchart/src/__snapshots__/BpkBarchart-test.js.snap +++ b/packages/bpk-component-barchart/src/__snapshots__/BpkBarchart-test.js.snap @@ -387,6 +387,393 @@ exports[`BpkBarchart should render correctly 1`] = ` `; +exports[`BpkBarchart should render correctly with "className" prop 1`] = ` + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ Month + + Average price (£) +
+ Jan + + 305 +
+ Feb + + 348 +
+ Mar + + 418 +
+ Apr + + 448 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +`; + exports[`BpkBarchart should render correctly with "leadingScrollIndicatorClassName" prop 1`] = `