Skip to content

Commit

Permalink
feat: deprecate old SuperChart API that accepts chartProps (apache-su…
Browse files Browse the repository at this point in the history
…perset#202)

BREAKING CHANGE: No longer accept chartProps as a single prop in <SuperChart>. Developers must specify each field in chartProps individually.
  • Loading branch information
kristw authored Aug 14, 2019
1 parent 630d3e5 commit af877c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 134 deletions.
65 changes: 0 additions & 65 deletions packages/superset-ui-chart/src/components/SuperChartShell.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/superset-ui-chart/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export { default as ChartProps } from './models/ChartProps';

export { default as createLoadableRenderer } from './components/createLoadableRenderer';
export { default as reactify } from './components/reactify';
export { default as SuperChart } from './components/SuperChartShell';
export { default as SuperChart } from './components/SuperChart';

export {
default as getChartBuildQueryRegistry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jest.mock('resize-observer-polyfill');
// @ts-ignore
import { triggerResizeObserver } from 'resize-observer-polyfill';
import ErrorBoundary from 'react-error-boundary';
import { ChartProps, SuperChart } from '../../src';
import { SuperChart } from '../../src';
import RealSuperChart from '../../src/components/SuperChart';
import { ChartKeys, DiligentChartPlugin, BuggyChartPlugin } from './MockChartPlugins';
import promiseTimeout from './promiseTimeout';
Expand Down Expand Up @@ -97,47 +97,15 @@ describe('SuperChart', () => {
});
});

describe('supports multiple way of specifying chartProps', () => {
it('chartProps is instanceof ChartProps', () => {
const wrapper = mount(
<SuperChart
chartType={ChartKeys.DILIGENT}
chartProps={new ChartProps({ width: 20, height: 20 })}
/>,
);

return promiseTimeout(() => {
const renderedWrapper = wrapper.render();
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
expectDimension(renderedWrapper, 20, 20);
});
});
it('chartProps is ChartPropsConfig', () => {
const wrapper = mount(
<SuperChart chartType={ChartKeys.DILIGENT} chartProps={{ width: 201, height: 202 }} />,
);
it('passes the props to renderer correctly', () => {
const wrapper = mount(
<SuperChart chartType={ChartKeys.DILIGENT} width={101} height={118} formData={{ abc: 1 }} />,
);

return promiseTimeout(() => {
const renderedWrapper = wrapper.render();
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
expectDimension(renderedWrapper, 201, 202);
});
});
it('fields of chartProps are listed as props of SuperChart', () => {
const wrapper = mount(
<SuperChart
chartType={ChartKeys.DILIGENT}
width={101}
height={118}
formData={{ abc: 1 }}
/>,
);

return promiseTimeout(() => {
const renderedWrapper = wrapper.render();
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
expectDimension(renderedWrapper, 101, 118);
});
return promiseTimeout(() => {
const renderedWrapper = wrapper.render();
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
expectDimension(renderedWrapper, 101, 118);
});
});

Expand Down Expand Up @@ -191,33 +159,6 @@ describe('SuperChart', () => {
const wrapper = mount(<SuperChart chartType={ChartKeys.DILIGENT} debounceTime={1} />);
triggerResizeObserver();

return promiseTimeout(() => {
const renderedWrapper = wrapper.render();
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
expectDimension(renderedWrapper, 300, 400);
}, 100);
});
it('works when width and height are inside chartProps', () => {
const wrapper = mount(
<SuperChart
chartType={ChartKeys.DILIGENT}
debounceTime={1}
chartProps={{ width: 123, height: 456 }}
/>,
);

return promiseTimeout(() => {
const renderedWrapper = wrapper.render();
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
expectDimension(renderedWrapper, 123, 456);
}, 100);
});
it('works when there is chartProps but still no width and height', () => {
const wrapper = mount(
<SuperChart chartType={ChartKeys.DILIGENT} debounceTime={1} chartProps={{}} />,
);
triggerResizeObserver();

return promiseTimeout(() => {
const renderedWrapper = wrapper.render();
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
Expand Down

0 comments on commit af877c6

Please sign in to comment.