Skip to content

Commit 9537c68

Browse files
Ming Xiaoreidmit
authored andcommitted
table can determine column headers from just the data [#153234166]
Signed-off-by: Reid Mitchell <rmitchell@pivotal.io>
1 parent 15f0595 commit 9537c68

File tree

5 files changed

+251
-181
lines changed

5 files changed

+251
-181
lines changed

spec/pivotal-ui-react/table/plugins/sorting_spec.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,40 @@ import '../../spec_helper';
22
import {Table, withSorting} from '../../../../src/react/table';
33

44
describe('withSorting', () => {
5+
let data, ComposedTable;
56
beforeEach(() => {
6-
const columns = [{
7-
attribute: 'attr1'
8-
}, {
9-
attribute: 'attr2', displayName: 'Display2'
10-
}];
11-
const data = [{
7+
data = [{
128
attr1: 'row1-value1', attr2: 'row1-value2'
139
}, {
1410
attr1: 'row2-value1', attr2: 'row2-value2'
1511
}];
12+
ComposedTable = withSorting(Table);
13+
});
14+
15+
describe('with columns', () => {
16+
beforeEach(() => {
17+
const columns = [{
18+
attribute: 'attr1'
19+
}, {
20+
attribute: 'attr2', displayName: 'Display2'
21+
}];
22+
23+
ReactDOM.render(<ComposedTable {...{columns, data, className: 'sorting-table'}}/>, root);
24+
});
1625

17-
const ComposedTable = withSorting(Table);
18-
ReactDOM.render(<ComposedTable {...{columns, data}}/>, root);
26+
it('renders', () => {
27+
expect('.sorting-table').toExist();
28+
});
1929
});
30+
31+
describe('without columns', () => {
32+
beforeEach(() => {
33+
ReactDOM.render(<ComposedTable {...{data, className: 'sorting-table'}}/>, root);
34+
});
35+
36+
it('renders', () => {
37+
expect('.sorting-table').toExist();
38+
});
39+
});
40+
2041
});

0 commit comments

Comments
 (0)