Skip to content

Commit

Permalink
fix(react-grid-material-ui): support indeterminate state for the sele…
Browse files Browse the repository at this point in the history
…ct all checkbox (#231)
  • Loading branch information
gsobolev committed Aug 1, 2017
1 parent 605cccc commit 6a5aab3
Show file tree
Hide file tree
Showing 21 changed files with 475 additions and 326 deletions.
200 changes: 124 additions & 76 deletions packages/dx-react-demos/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/dx-react-demos/package.json
Expand Up @@ -39,7 +39,7 @@
"@devexpress/dx-react-grid-bootstrap3": "1.0.0-alpha.6",
"@devexpress/dx-react-grid-material-ui": "1.0.0-alpha.6",
"core-js": "^2.4.1",
"material-ui": "1.0.0-alpha.21",
"material-ui": "1.0.0-beta.3",
"material-ui-icons": "1.0.0-alpha.19",
"prop-types": "^15.5.8",
"react": "^15.6.1",
Expand Down
Expand Up @@ -35,17 +35,19 @@ export const TableSelectAllCell = (
/>
</th>
);
TableSelectAllCell.defaultProps = {
style: null,
allSelected: false,
someSelected: false,
selectionAvailable: false,
toggleAll: () => {},
};

TableSelectAllCell.propTypes = {
style: PropTypes.shape(),
allSelected: PropTypes.bool,
someSelected: PropTypes.bool,
selectionAvailable: PropTypes.bool,
toggleAll: PropTypes.func,
};

TableSelectAllCell.defaultProps = {
style: null,
allSelected: false,
someSelected: false,
selectionAvailable: false,
toggleAll: () => {},
};
@@ -0,0 +1,45 @@
import React from 'react';
import { mount } from 'enzyme';
import { setupConsole } from '@devexpress/dx-testing';
import { TableSelectAllCell } from './table-select-all-cell';

describe('TableHeaderCell', () => {
let resetConsole;
beforeAll(() => {
resetConsole = setupConsole({ ignore: ['validateDOMNesting'] });
});
afterAll(() => {
resetConsole();
});

it('should render indeterminate state checkbox if the `someSelected` property is true', () => {
const tree = mount(
<TableSelectAllCell
column={{
name: 'Test',
}}
someSelected
/>,
);

expect(tree.find('input').getNode().indeterminate)
.toBeTruthy();
});

it('should call the `toggleAll` function on cell click if selection is available', () => {
const toggleAll = jest.fn();
const tree = mount(
<TableSelectAllCell
column={{
name: 'Test',
}}
selectionAvailable
toggleAll={toggleAll}
/>,
);
tree.find('input').simulate('change');

expect(toggleAll)
.toHaveBeenCalledTimes(1);
});
});

0 comments on commit 6a5aab3

Please sign in to comment.