This commit is contained in:
parent
209e7a9d91
commit
30f88caf55
|
|
@ -57,7 +57,7 @@ describe('TableElement', () => {
|
|||
expect(wrapper.find(ColumnElement).first().props().column.name).toBe('id');
|
||||
wrapper.find('.sort-cols').simulate('click');
|
||||
expect(wrapper.state().sortColumns).toBe(true);
|
||||
expect(wrapper.find(ColumnElement).first().props().column.name).toBe('last_login');
|
||||
expect(wrapper.find(ColumnElement).first().props().column.name).toBe('active');
|
||||
});
|
||||
it('calls the collapseTable action', () => {
|
||||
const wrapper = mount(<TableElement {...mockedProps} />);
|
||||
|
|
|
|||
|
|
@ -204,7 +204,16 @@ class TableElement extends React.PureComponent {
|
|||
if (table.columns) {
|
||||
cols = table.columns.slice();
|
||||
if (this.state.sortColumns) {
|
||||
cols.sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase());
|
||||
cols.sort((a, b) => {
|
||||
const colA = a.name.toUpperCase();
|
||||
const colB = b.name.toUpperCase();
|
||||
if (colA < colB) {
|
||||
return -1;
|
||||
} else if (colA > colB) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
const metadata = (
|
||||
|
|
|
|||
Loading…
Reference in New Issue