Skip to content

Commit

Permalink
fix: broken tests, update prop naming
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Jun 8, 2020
1 parent 44e5101 commit 9c91e74
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/components/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ export class Chart extends React.Component<ChartProps, ChartState> {

render() {
const { size, className } = this.props;
const containerStyle = getChartSize(size);
const containerSizeStyle = getChartSize(size);
const horizontal = isHorizontalAxis(this.state.legendPosition);
const chartClassNames = classNames('echChart', className, {
'echChart--column': horizontal,
});

return (
<Provider store={this.chartStore}>
<div className={chartClassNames} style={containerStyle} ref={this.chartContainerRef}>
<div className={chartClassNames} style={containerSizeStyle} ref={this.chartContainerRef}>
<ChartBackground />
<ChartStatus />
<ChartResizer />
Expand Down
10 changes: 5 additions & 5 deletions src/components/chart_background.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { GlobalChartState } from '../state/chart_state';
import { getInternalIsInitializedSelector } from '../state/selectors/get_internal_is_intialized';

interface ChartBackgroundProps {
background: string;
backgroundColor: string;
}

export class ChartBackgroundComponent extends React.Component<ChartBackgroundProps> {
Expand All @@ -33,19 +33,19 @@ export class ChartBackgroundComponent extends React.Component<ChartBackgroundPro
}

render() {
const { background } = this.props;
return <div className="echChartBackground" style={{ background }} />;
const { backgroundColor } = this.props;
return <div className="echChartBackground" style={{ backgroundColor }} />;
}
}

const mapStateToProps = (state: GlobalChartState): ChartBackgroundProps => {
if (!getInternalIsInitializedSelector(state)) {
return {
background: 'transparent',
backgroundColor: 'transparent',
};
}
return {
background: getChartThemeSelector(state).background.color,
backgroundColor: getChartThemeSelector(state).background.color,
};
};

Expand Down
13 changes: 0 additions & 13 deletions src/utils/chart_size.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,71 +21,58 @@ import { getChartSize } from './chart_size';
describe('chart size utilities', () => {
test('array', () => {
expect(getChartSize([100, 100])).toEqual({
position: 'relative',
width: 100,
height: 100,
});
expect(getChartSize([undefined, 100])).toEqual({
position: 'relative',
width: '100%',
height: 100,
});
expect(getChartSize([100, undefined])).toEqual({
position: 'relative',
width: 100,
height: '100%',
});
expect(getChartSize([undefined, undefined])).toEqual({
position: 'relative',
width: '100%',
height: '100%',
});
expect(getChartSize([0, '100em'])).toEqual({
position: 'relative',
width: 0,
height: '100em',
});
});
test('value', () => {
expect(getChartSize(1)).toEqual({
position: 'relative',
width: 1,
height: 1,
});
expect(getChartSize('100em')).toEqual({
position: 'relative',
width: '100em',
height: '100em',
});
expect(getChartSize(0)).toEqual({
position: 'relative',
width: 0,
height: 0,
});
});
test('object', () => {
expect(getChartSize({ width: 100, height: 100 })).toEqual({
position: 'relative',
width: 100,
height: 100,
});
expect(getChartSize({ height: 100 })).toEqual({
position: 'relative',
width: '100%',
height: 100,
});
expect(getChartSize({ width: 100 })).toEqual({
position: 'relative',
width: 100,
height: '100%',
});
expect(getChartSize({})).toEqual({
position: 'relative',
width: '100%',
height: '100%',
});
expect(getChartSize({ width: 0, height: '100em' })).toEqual({
position: 'relative',
width: 0,
height: '100em',
});
Expand Down

0 comments on commit 9c91e74

Please sign in to comment.