Skip to content

Commit 7953d23

Browse files
committed
Add tests for node.disabled.
Closes #49.
1 parent 6a97f9f commit 7953d23

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

test/CheckboxTree.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,68 @@ describe('<CheckboxTree />', () => {
142142
assert.deepEqual(['io', 'europa'], actual);
143143
});
144144
});
145+
146+
describe('nodeProps', () => {
147+
describe('disabled', () => {
148+
it('should disable the target node when set to true', () => {
149+
const wrapper = shallow(
150+
<CheckboxTree
151+
nodes={[
152+
{
153+
value: 'jupiter',
154+
label: 'Jupiter',
155+
disabled: true,
156+
children: [
157+
{ value: 'europa', label: 'Europa' },
158+
],
159+
},
160+
]}
161+
/>,
162+
);
163+
164+
assert.isTrue(wrapper.find(TreeNode).prop('disabled'));
165+
});
166+
167+
it('should disable the child nodes when `noCascade` is false', () => {
168+
const wrapper = shallow(
169+
<CheckboxTree
170+
expanded={['jupiter']}
171+
nodes={[
172+
{
173+
value: 'jupiter',
174+
label: 'Jupiter',
175+
disabled: true,
176+
children: [
177+
{ value: 'europa', label: 'Europa' },
178+
],
179+
},
180+
]}
181+
/>,
182+
);
183+
184+
assert.isTrue(wrapper.find('TreeNode[value="europa"]').prop('disabled'));
185+
});
186+
187+
it('should NOT disable the child nodes when `noCascade` is true', () => {
188+
const wrapper = shallow(
189+
<CheckboxTree
190+
expanded={['jupiter']}
191+
noCascade
192+
nodes={[
193+
{
194+
value: 'jupiter',
195+
label: 'Jupiter',
196+
disabled: true,
197+
children: [
198+
{ value: 'europa', label: 'Europa' },
199+
],
200+
},
201+
]}
202+
/>,
203+
);
204+
205+
assert.isFalse(wrapper.find('TreeNode[value="europa"]').prop('disabled'));
206+
});
207+
});
208+
});
145209
});

0 commit comments

Comments
 (0)