@@ -4,6 +4,17 @@ import { assert } from 'chai';
44
55import TreeNode from '../src/js/TreeNode' ;
66
7+ const baseProps = {
8+ checked : 0 ,
9+ expanded : false ,
10+ label : 'Jupiter' ,
11+ optimisticToggle : true ,
12+ treeId : 'id' ,
13+ value : 'jupiter' ,
14+ onCheck : ( ) => { } ,
15+ onExpand : ( ) => { } ,
16+ } ;
17+
718describe ( '<TreeNode />' , ( ) => {
819 describe ( 'component' , ( ) => {
920 it ( 'should render the rct-node container' , ( ) => {
@@ -45,6 +56,44 @@ describe('<TreeNode />', () => {
4556 } ) ;
4657 } ) ;
4758
59+ describe ( 'checked' , ( ) => {
60+ it ( 'should render icons associated with each check state' , ( ) => {
61+ const iconMap = {
62+ 0 : < i className = "fa fa-square-o" /> ,
63+ 1 : < i className = "fa fa-check-square-o" /> ,
64+ 2 : < i className = "fa fa-check-square-o rct-half-checked" /> ,
65+ } ;
66+
67+ Object . keys ( iconMap ) . forEach ( ( state ) => {
68+ const wrapper = shallow (
69+ < TreeNode { ...baseProps } checked = { parseInt ( state , 10 ) } /> ,
70+ ) ;
71+
72+ assert . isTrue ( wrapper . contains ( iconMap [ state ] ) ) ;
73+ } ) ;
74+ } ) ;
75+
76+ it ( 'should render an unchecked input element when not set to 1' , ( ) => {
77+ const wrapper1 = shallow (
78+ < TreeNode { ...baseProps } checked = { 0 } /> ,
79+ ) ;
80+ const wrapper2 = shallow (
81+ < TreeNode { ...baseProps } checked = { 2 } /> ,
82+ ) ;
83+
84+ assert . isFalse ( wrapper1 . find ( 'input[type="checkbox"]' ) . prop ( 'checked' ) ) ;
85+ assert . isFalse ( wrapper2 . find ( 'input[type="checkbox"]' ) . prop ( 'checked' ) ) ;
86+ } ) ;
87+
88+ it ( 'should render a checked input element when set to 1' , ( ) => {
89+ const wrapper = shallow (
90+ < TreeNode { ...baseProps } checked = { 1 } /> ,
91+ ) ;
92+
93+ assert . isTrue ( wrapper . find ( 'input[type="checkbox"]' ) . prop ( 'checked' ) ) ;
94+ } ) ;
95+ } ) ;
96+
4897 describe ( 'expanded' , ( ) => {
4998 it ( 'should render children when set to true' , ( ) => {
5099 const wrapper = shallow (
0 commit comments