Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Commit 2f25555

Browse files
committed
test(legacy-table): more sophisticated cases
1 parent cdaf494 commit 2f25555

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

packages/superset-ui-legacy-plugin-chart-table/test/ReactDataTable.test.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,30 @@ describe('legacy-table', () => {
3636
});
3737

3838
let wrap: any; // the SuperChart wraper
39-
let tree: any; // helper to dive into DOM tree
4039

4140
it('render basic data', () => {
4241
wrap = mount(<ReactDataTable {...transformProps(testData.basic)} />);
43-
tree = wrap.render(); // returns a CheerioWrapper with jQuery-like API
42+
const tree = wrap.render(); // returns a CheerioWrapper with jQuery-like API
43+
const cells = tree.find('td');
4444
expect(tree.hasClass('superset-legacy-chart-table')).toEqual(true);
45-
expect(tree.find('td[data-sort="Michael"]')).toHaveLength(1);
45+
expect(cells).toHaveLength(4);
46+
expect(cells.eq(0).text()).toEqual('Michael');
47+
expect(cells.eq(3).attr('data-sort')).toEqual('2467');
4648
});
4749

4850
it('render advanced data', () => {
4951
// should successfull rerender with new props
5052
wrap.setProps(transformProps(testData.advanced));
51-
tree = wrap.render();
52-
const text = tree.text();
53-
expect(text).toContain('Sum of Num');
54-
expect(text).toContain('12.346%');
53+
const tree = wrap.render();
54+
const cells = tree.find('td');
55+
expect(
56+
tree
57+
.find('th')
58+
.eq(1)
59+
.text(),
60+
).toEqual('Sum of Num');
61+
expect(cells.eq(2).text()).toEqual('12.346%');
62+
expect(cells.eq(4).text()).toEqual('2.47k');
5563
});
5664
});
5765
});

packages/superset-ui-legacy-plugin-chart-table/test/test_data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const basic: ChartProps = {
7979
/**
8080
* Advanced data input with
8181
* - verbose map
82-
* - percent metrics
82+
* - metric columns
8383
*/
8484
export const advanced: ChartProps = {
8585
...basic,
@@ -91,6 +91,7 @@ export const advanced: ChartProps = {
9191
},
9292
formData: {
9393
...basicFormData,
94+
metrics: ['sum__num'],
9495
percentMetrics: ['pct_nice'],
9596
},
9697
queryData: {

0 commit comments

Comments
 (0)