@@ -120,36 +120,66 @@ describe('orgchart -- unit tests', function () {
120
120
oc2 . getHierarchy ( ) . should . include ( 'Error' ) ;
121
121
} ) ;
122
122
123
- it ( 'getNodeState()' , function ( ) {
124
- oc . init ( { 'depth' : 2 } ) . $chart . on ( 'init.orgchart' , function ( ) {
125
- oc . getNodeState ( $laolao , 'parent' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } ) ;
126
- oc . getNodeState ( $laolao , 'children' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } ) ;
127
- oc . getNodeState ( $laolao , 'siblings' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } ) ;
128
-
129
- oc . getNodeState ( $bomiao , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } ) ;
130
- oc . getNodeState ( $bomiao , 'children' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } ) ;
131
- oc . getNodeState ( $bomiao , 'siblings' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } ) ;
132
-
133
- oc . getNodeState ( $sumiao , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } ) ;
134
- oc . getNodeState ( $sumiao , 'children' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } ) ;
135
- oc . getNodeState ( $sumiao , 'siblings' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } ) ;
136
-
137
- oc . getNodeState ( $tiehua , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } ) ;
138
- oc . getNodeState ( $tiehua , 'children' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } ) ;
139
- oc . getNodeState ( $tiehua , 'siblings' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } ) ;
140
-
141
- oc . getNodeState ( $heihei , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } ) ;
142
- oc . getNodeState ( $heihei , 'children' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } ) ;
143
- oc . getNodeState ( $heihei , 'siblings' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } ) ;
144
-
145
- oc . getNodeState ( $pangpang , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } ) ;
146
- oc . getNodeState ( $pangpang , 'children' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } ) ;
147
- oc . getNodeState ( $pangpang , 'siblings' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } ) ;
148
-
149
- oc . getNodeState ( $dandan , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } ) ;
150
- oc . getNodeState ( $dandan , 'children' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } ) ;
151
- oc . getNodeState ( $dandan , 'siblings' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } ) ;
152
- } ) ;
123
+ it ( 'getNodeState()' , function ( done ) {
124
+ var check = function ( ) {
125
+ try {
126
+ $laolao = $ ( '#n1' ) ;
127
+ $bomiao = $ ( '#n2' ) ;
128
+ $sumiao = $ ( '#n3' ) ;
129
+ $hongmiao = $ ( '#n4' ) ;
130
+ $tiehua = $ ( '#n5' ) ;
131
+ $heihei = $ ( '#n6' ) ;
132
+ $pangpang = $ ( '#n7' ) ;
133
+ $dandan = $ ( '#n8' ) ;
134
+ $erdan = $ ( '#n9' ) ;
135
+ $sandan = $ ( '#n10' ) ;
136
+
137
+ oc . getNodeState ( $laolao ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "laolao->self" ) ;
138
+ oc . getNodeState ( $laolao , 'parent' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } , "laolao->parent" ) ;
139
+ oc . getNodeState ( $laolao , 'children' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "laolao->children" ) ;
140
+ oc . getNodeState ( $laolao , 'siblings' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } , "laolao->siblings" ) ;
141
+
142
+ oc . getNodeState ( $bomiao ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "bomiao->self" ) ;
143
+ oc . getNodeState ( $bomiao , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "bomiao->parent" ) ;
144
+ oc . getNodeState ( $bomiao , 'children' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } , "bomiao->children" ) ;
145
+ oc . getNodeState ( $bomiao , 'siblings' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "bomiao->siblings" ) ;
146
+
147
+ oc . getNodeState ( $sumiao ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "sumiao->self" ) ;
148
+ oc . getNodeState ( $sumiao , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "sumiao->parent" ) ;
149
+ oc . getNodeState ( $sumiao , 'children' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "sumiao->children" ) ;
150
+ oc . getNodeState ( $sumiao , 'siblings' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "sumiao->siblings" ) ;
151
+
152
+ oc . getNodeState ( $tiehua ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "tiehua->self" ) ;
153
+ oc . getNodeState ( $tiehua , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "tiehua->parent" ) ;
154
+ oc . getNodeState ( $tiehua , 'children' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "tiehua->children" ) ;
155
+ oc . getNodeState ( $tiehua , 'siblings' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "tiehua->siblings" ) ;
156
+
157
+ oc . getNodeState ( $heihei ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "heihei->self" ) ;
158
+ oc . getNodeState ( $heihei , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "heihei->parent" ) ;
159
+ oc . getNodeState ( $heihei , 'children' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "heihei->children" ) ;
160
+ oc . getNodeState ( $heihei , 'siblings' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "heihei->siblings" ) ;
161
+
162
+ oc . getNodeState ( $pangpang ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "pangpang->self" ) ;
163
+ oc . getNodeState ( $pangpang , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : true } , "pangpang->parent" ) ;
164
+ oc . getNodeState ( $pangpang , 'children' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "pangpang->children" ) ;
165
+ oc . getNodeState ( $pangpang , 'siblings' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "pangpang->siblings" ) ;
166
+
167
+ oc . getNodeState ( $dandan ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "dandan->self" ) ;
168
+ oc . getNodeState ( $dandan , 'parent' ) . should . deep . equal ( { 'exist' : true , 'visible' : false } , "dandan->parent" ) ;
169
+ oc . getNodeState ( $dandan , 'children' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } , "dandan->children" ) ;
170
+ oc . getNodeState ( $dandan , 'siblings' ) . should . deep . equal ( { 'exist' : false , 'visible' : false } , "dandan->siblings" ) ;
171
+
172
+ done ( ) ;
173
+ } catch ( err ) {
174
+ done ( err ) ;
175
+ }
176
+ } ;
177
+ if ( typeof MutationObserver !== 'undefined' ) {
178
+ oc . init ( { 'visibleLevel' : 2 , 'verticalLevel' : 3 } ) . $chart . on ( 'init.orgchart' , check ) ;
179
+ } else {
180
+ oc . init ( { 'visibleLevel' : 2 , 'verticalLevel' : 3 } ) ;
181
+ setTimeout ( check , 500 ) ;
182
+ }
153
183
} ) ;
154
184
155
185
it ( 'getRelatedNodes()' , function ( ) {
0 commit comments