Skip to content

Commit

Permalink
table can determine column headers from just the data [#153234166]
Browse files Browse the repository at this point in the history
Signed-off-by: Reid Mitchell <rmitchell@pivotal.io>
  • Loading branch information
Ming Xiao authored and reidmit committed Nov 28, 2017
1 parent 15f0595 commit 9537c68
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 181 deletions.
37 changes: 29 additions & 8 deletions spec/pivotal-ui-react/table/plugins/sorting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,40 @@ import '../../spec_helper';
import {Table, withSorting} from '../../../../src/react/table';

describe('withSorting', () => {
let data, ComposedTable;
beforeEach(() => {
const columns = [{
attribute: 'attr1'
}, {
attribute: 'attr2', displayName: 'Display2'
}];
const data = [{
data = [{
attr1: 'row1-value1', attr2: 'row1-value2'
}, {
attr1: 'row2-value1', attr2: 'row2-value2'
}];
ComposedTable = withSorting(Table);
});

describe('with columns', () => {
beforeEach(() => {
const columns = [{
attribute: 'attr1'
}, {
attribute: 'attr2', displayName: 'Display2'
}];

ReactDOM.render(<ComposedTable {...{columns, data, className: 'sorting-table'}}/>, root);
});

const ComposedTable = withSorting(Table);
ReactDOM.render(<ComposedTable {...{columns, data}}/>, root);
it('renders', () => {
expect('.sorting-table').toExist();
});
});

describe('without columns', () => {
beforeEach(() => {
ReactDOM.render(<ComposedTable {...{data, className: 'sorting-table'}}/>, root);
});

it('renders', () => {
expect('.sorting-table').toExist();
});
});

});
Loading

0 comments on commit 9537c68

Please sign in to comment.