Skip to content

Commit

Permalink
Merge pull request #154 from TechnologyAdvice/feature/table-sortable-…
Browse files Browse the repository at this point in the history
…class

Automatic sortable table class
  • Loading branch information
levithomason committed Jan 28, 2016
2 parents ab635b9 + 5988e56 commit 8480aad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/collections/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default class Table extends Component {
const classes = classNames(
'sd-table',
'ui',
{sortable: !!this.props.onSortChange},
this.props.className,
'table'
);
Expand Down
18 changes: 18 additions & 0 deletions test/specs/collections/Table/Table-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,22 @@ describe('Table', () => {
});
});
});

describe('sortable', () => {
describe('with onSortChange prop', () => {
it('has class "sortable"', () => {
render(<Table data={tableData} onSortChange={_.noop} />)
.findClass('sortable');
});
});

describe('without onSortChange prop', () => {
it('does not have class "sortable"', () => {
render(<Table data={tableData} />)
.findClass('sd-table')
.props.className
.should.not.include('sortable');
});
});
});
});

0 comments on commit 8480aad

Please sign in to comment.