Skip to content

Commit

Permalink
Update: Tree picker node component to support child nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
pphminions authored and omgaz committed Dec 6, 2016
1 parent 8fc657a commit 6054fbf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class AppComponent extends React.Component {
],
treePickerPureSubtree: [],
selectedNodes: [
{ id: '2', label: 'Norfolk Island', path: [{ id: '11', label: 'AU' }], type: '', isSelectable: false },
{ id: '2', label: 'Norfolk Island', path: [], type: '', isSelectable: false },
{ id: '3', label: 'Queensland', path: [{ id: '12', label: 'AU' }], type: '' },
],
searchBarString: '',
Expand Down
2 changes: 1 addition & 1 deletion src/components/adslotUi/TreePickerNodeComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const TreePickerNodeComponent = ({
const labelCellProps = expanderElement ? { onClick: expandNodeBound } : {};

return (
<div className={`${baseClass}`}>
<div className={!_.isEmpty(node.path) || !_.isEmpty(node.ancestors) ? `${baseClass} child-node` : `${baseClass}`}>
<GridRow dts={`${_.kebabCase(itemType)}-${node.id}`}>
{selected ?
<GridCell classSuffixes={['button']} dts="button-remove">
Expand Down
11 changes: 10 additions & 1 deletion test/components/adslotUi/TreePickerNodeComponentTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('TreePickerNodeComponent', () => {

it('should render a node with defaults', () => {
const component = shallow(<TreePickerNodeComponent itemType={itemType} node={cbrNode} />);
expect(component.prop('className')).to.equal('treepickernode-component');
expect(component.prop('className')).to.equal('treepickernode-component child-node');
expect(component.type()).to.equal('div');

const rowElement = component.find(GridRow);
Expand Down Expand Up @@ -143,6 +143,15 @@ describe('TreePickerNodeComponent', () => {
expect(valueCellElement).to.be.a('null');
});

it('should have the child node class for child nodes', () => {
const node = _.clone(cbrNode);
node.path = [{ id: 1, label: 'AU' }];
const props = { itemType, node };
const component = shallow(<TreePickerNodeComponent {...props} />);

expect(component.prop('className')).to.equal('treepickernode-component child-node');
});

it('should fire expandNode when clicking on the `expand` cell', () => {
const nodes = [];
const expandNode = (node) => nodes.push(node);
Expand Down

0 comments on commit 6054fbf

Please sign in to comment.