fix(legacy-plugin-chart-table): parse numeric pageLength (#522)

This commit is contained in:
Jesse Yang 2020-05-21 16:42:50 -07:00 committed by Yongjie Zhao
parent 8776262499
commit 6d04279daf
3 changed files with 19 additions and 3 deletions

View File

@ -138,7 +138,7 @@ export default function transformProps(chartProps: TableChartProps): DataTablePr
showCellBars,
includeSearch,
orderDesc,
pageLength: typeof pageLength === 'string' ? parseInt(pageLength, 10) || 0 : 0,
pageLength: typeof pageLength === 'string' ? parseInt(pageLength, 10) || 0 : pageLength,
tableTimestampFormat,
filters,
emitFilter: tableFilter === true,

View File

@ -24,7 +24,23 @@ import testData from './testData';
describe('legacy-table', () => {
// Can test more prop transformation here. Not needed for now.
describe('transformProps', () => {});
describe('transformProps', () => {
it('should parse pageLength', () => {
expect(transformProps(testData.basic).pageLength).toBe(20);
expect(
transformProps({
...testData.basic,
formData: { ...testData.basic.formData, pageLength: '20' },
}).pageLength,
).toBe(20);
expect(
transformProps({
...testData.basic,
formData: { ...testData.basic.formData, pageLength: '' },
}).pageLength,
).toBe(0);
});
});
describe('ReactDataTable', () => {
let wrap: CommonWrapper; // the ReactDataTable wraper

View File

@ -26,7 +26,7 @@ const basicFormData = {
showCellBars: true,
includeSearch: false,
orderDesc: true,
pageLength: 0,
pageLength: 20,
metrics: [],
percentMetrics: null,
timeseriesLimitMetric: null,