-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5845 from oliviertassinari/table-add-integration-…
…test [Table] Add an integration test
- Loading branch information
Showing
10 changed files
with
146 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import { | ||
Table, | ||
TableBody, | ||
TableHeader, | ||
TableHeaderColumn, | ||
TableRow, | ||
TableRowColumn, | ||
} from 'src/Table'; | ||
|
||
const tableData = [ | ||
{ | ||
name: 'John Smith', | ||
selected: true, | ||
}, | ||
{ | ||
name: 'Randal White', | ||
selected: true, | ||
}, | ||
{ | ||
name: 'Olivier', | ||
}, | ||
]; | ||
|
||
function TableMutliSelect() { | ||
return ( | ||
<Table | ||
selectable={true} | ||
multiSelectable={true} | ||
> | ||
<TableHeader | ||
displaySelectAll={true} | ||
adjustForCheckbox={true} | ||
enableSelectAll={true} | ||
> | ||
<TableRow> | ||
<TableHeaderColumn> | ||
Name | ||
</TableHeaderColumn> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody displayRowCheckbox={true}> | ||
{tableData.map( (row, index) => ( | ||
<TableRow key={index} selected={row.selected}> | ||
<TableRowColumn> | ||
{row.name} | ||
</TableRowColumn> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
); | ||
} | ||
|
||
export default TableMutliSelect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* eslint-env mocha */ | ||
import React from 'react'; | ||
import {mount} from 'enzyme'; | ||
import {assert} from 'chai'; | ||
import getMuiTheme from 'src/styles/getMuiTheme'; | ||
import MultiSelectTable from './MultiSelectTable'; | ||
|
||
describe('<MultiSelectTable />', () => { | ||
it('should select and unselect every checkboxes', () => { | ||
const muiTheme = getMuiTheme(); | ||
const mountWithContext = (node) => mount(node, { | ||
context: {muiTheme}, | ||
childContextTypes: {muiTheme: React.PropTypes.object}, | ||
}); | ||
|
||
const wrapper = mountWithContext( | ||
<MultiSelectTable /> | ||
); | ||
|
||
assert.deepEqual( | ||
wrapper.find('Checkbox').map((checkbox) => checkbox.props().checked), | ||
[ | ||
false, | ||
true, | ||
true, | ||
false, | ||
], | ||
'should use the selected property for the initial value' | ||
); | ||
|
||
let input; | ||
input = wrapper.find('Checkbox').at(0).find('input'); | ||
input.node.checked = !input.node.checked; | ||
input.simulate('change'); | ||
|
||
assert.deepEqual( | ||
wrapper.find('Checkbox').map((checkbox) => checkbox.props().checked), | ||
[ | ||
true, | ||
true, | ||
true, | ||
true, | ||
], | ||
'should check all the checkboxes' | ||
); | ||
|
||
input = wrapper.find('Checkbox').at(0).find('input'); | ||
input.node.checked = !input.node.checked; | ||
input.simulate('change'); | ||
|
||
assert.deepEqual( | ||
wrapper.find('Checkbox').map((checkbox) => checkbox.props().checked), | ||
[ | ||
false, | ||
false, | ||
false, | ||
false, | ||
], | ||
'should uncheck all the checkboxes' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters