File tree Expand file tree Collapse file tree 1 file changed +57
-47
lines changed Expand file tree Collapse file tree 1 file changed +57
-47
lines changed Original file line number Diff line number Diff line change @@ -46,129 +46,129 @@ describe('treeCtrl', function () {
46
46
47
47
scope . list = [
48
48
{
49
- 'id' : 1 ,
50
- 'title' : 'item1 ' ,
49
+ 'id' : 0 ,
50
+ 'title' : 'item0 ' ,
51
51
'items' : [ ]
52
52
} ,
53
53
{
54
- 'id' : 2 ,
55
- 'title' : 'item2 ' ,
54
+ 'id' : 1 ,
55
+ 'title' : 'item1 ' ,
56
56
'items' : [
57
57
{
58
- 'id' : 21 ,
59
- 'title' : 'item2.1 ' ,
58
+ 'id' : 10 ,
59
+ 'title' : 'item1.0 ' ,
60
60
'items' : [
61
61
{
62
- 'id' : 211 ,
63
- 'title' : 'item2.1.1 ' ,
62
+ 'id' : 100 ,
63
+ 'title' : 'item1.0.0 ' ,
64
64
'items' : [ ]
65
65
} ,
66
66
{
67
- 'id' : 212 ,
68
- 'title' : 'item2.1.2 ' ,
67
+ 'id' : 101 ,
68
+ 'title' : 'item1.0.1 ' ,
69
69
'items' : [ ]
70
70
} ,
71
71
{
72
- 'id' : 213 ,
73
- 'title' : 'item2.1.3 ' ,
72
+ 'id' : 102 ,
73
+ 'title' : 'item1.0.2 ' ,
74
74
'items' : [ ]
75
75
}
76
76
]
77
77
} ,
78
78
{
79
- 'id' : 22 ,
80
- 'title' : 'item2.2 ' ,
79
+ 'id' : 11 ,
80
+ 'title' : 'item1.1 ' ,
81
81
'items' : [ ]
82
82
} ,
83
83
{
84
- 'id' : 23 ,
85
- 'title' : 'item2.3 ' ,
84
+ 'id' : 12 ,
85
+ 'title' : 'item1.2 ' ,
86
86
'items' : [
87
87
{
88
- 'id' : 231 ,
89
- 'title' : 'item2.3.1 ' ,
88
+ 'id' : 120 ,
89
+ 'title' : 'item1.2.0 ' ,
90
90
'items' : [ ]
91
91
} ,
92
92
{
93
- 'id' : 232 ,
94
- 'title' : 'item2.3.2 ' ,
93
+ 'id' : 121 ,
94
+ 'title' : 'item1.2.1 ' ,
95
95
'items' : [ ]
96
96
} ,
97
97
{
98
- 'id' : 233 ,
99
- 'title' : 'item2.3.3 ' ,
98
+ 'id' : 122 ,
99
+ 'title' : 'item1.2.2 ' ,
100
100
'items' : [ ]
101
101
}
102
102
]
103
103
} ,
104
104
{
105
- 'id' : 24 ,
106
- 'title' : 'item2.4 ' ,
105
+ 'id' : 13 ,
106
+ 'title' : 'item1.3 ' ,
107
107
'items' : [
108
108
{
109
- 'id' : 241 ,
110
- 'title' : 'item2.4.1 ' ,
109
+ 'id' : 130 ,
110
+ 'title' : 'item1.3.0 ' ,
111
111
'items' : [ ]
112
112
} ,
113
113
{
114
- 'id' : 242 ,
115
- 'title' : 'item2.4.2 ' ,
114
+ 'id' : 131 ,
115
+ 'title' : 'item1.3.1 ' ,
116
116
'items' : [ ]
117
117
} ,
118
118
{
119
- 'id' : 243 ,
119
+ 'id' : 132 ,
120
120
'title' : 'item2.4.3' ,
121
121
'items' : [ ]
122
122
} ,
123
123
{
124
124
'id' : 244 ,
125
- 'title' : 'item2.4.4 ' ,
125
+ 'title' : 'item1.3.3 ' ,
126
126
'items' : [ ]
127
127
}
128
128
]
129
129
}
130
130
]
131
131
} ,
132
132
{
133
- 'id' : 3 ,
134
- 'title' : 'item3 ' ,
133
+ 'id' : 2 ,
134
+ 'title' : 'item2 ' ,
135
135
'items' : [
136
136
{
137
- 'id' : 31 ,
138
- 'title' : 'item3.1 ' ,
137
+ 'id' : 20 ,
138
+ 'title' : 'item2.0 ' ,
139
139
'items' : [ ]
140
140
} ,
141
141
{
142
- 'id' : 32 ,
143
- 'title' : 'item3.2 ' ,
142
+ 'id' : 21 ,
143
+ 'title' : 'item2.1 ' ,
144
144
'items' : [ ]
145
145
} ,
146
146
{
147
- 'id' : 33 ,
148
- 'title' : 'item3.3 ' ,
147
+ 'id' : 22 ,
148
+ 'title' : 'item2.2 ' ,
149
149
'items' : [
150
150
{
151
- 'id' : 331 ,
152
- 'title' : 'item3.3.1 ' ,
151
+ 'id' : 220 ,
152
+ 'title' : 'item2.2.0 ' ,
153
153
'items' : [ ]
154
154
} ,
155
155
{
156
- 'id' : 332 ,
157
- 'title' : 'item3.3.2 ' ,
156
+ 'id' : 221 ,
157
+ 'title' : 'item2.2.1 ' ,
158
158
'items' : [ ]
159
159
} ,
160
160
{
161
- 'id' : 333 ,
162
- 'title' : 'item3.3.3 ' ,
161
+ 'id' : 222 ,
162
+ 'title' : 'item2.2.2 ' ,
163
163
'items' : [ ]
164
164
}
165
165
]
166
166
}
167
167
]
168
168
} ,
169
169
{
170
- 'id' : 4 ,
171
- 'title' : 'item4 ' ,
170
+ 'id' : 3 ,
171
+ 'title' : 'item3 ' ,
172
172
'items' : [ ]
173
173
}
174
174
] ;
@@ -179,7 +179,7 @@ describe('treeCtrl', function () {
179
179
scope . $digest ( ) ;
180
180
return element ;
181
181
}
182
-
182
+
183
183
it ( 'should not include in depth calculation child node scopes with no children' , function ( ) {
184
184
var tree , localScope ;
185
185
tree = createTree ( ) ;
@@ -188,6 +188,16 @@ describe('treeCtrl', function () {
188
188
expect ( localScope . childNodes ( ) [ 1 ] . maxSubDepth ( ) ) . toEqual ( 2 ) ;
189
189
190
190
} ) ;
191
+
192
+ it ( 'should calculate the depth of any subtree' , function ( ) {
193
+ var tree , localScope ;
194
+ tree = createTree ( ) ;
195
+ localScope = angular . element ( tree . children ( 'ol' ) . first ( ) ) . scope ( ) ;
196
+ expect ( localScope . childNodes ( ) [ 0 ] . maxSubDepth ( ) ) . toEqual ( 0 ) ; // item0
197
+ expect ( localScope . childNodes ( ) [ 1 ] . maxSubDepth ( ) ) . toEqual ( 2 ) ; // item1
198
+ expect ( localScope . childNodes ( ) [ 1 ] . childNodes ( ) [ 0 ] . maxSubDepth ( ) ) . toEqual ( 1 ) ; // item1.0
199
+ expect ( localScope . childNodes ( ) [ 1 ] . childNodes ( ) [ 0 ] . childNodes ( ) [ 0 ] . maxSubDepth ( ) ) . toEqual ( 0 ) ; // item1.0.0
200
+ } ) ;
191
201
} ) ;
192
202
193
203
You can’t perform that action at this time.
0 commit comments