@@ -121,11 +121,22 @@ describe('OutlineViewAdapter', () => {
121
121
containerName : 'duplicate' ,
122
122
} ,
123
123
] ;
124
+
124
125
const result = OutlineViewAdapter . createOutlineTrees ( sourceItems ) ;
125
126
expect ( result . length ) . to . equal ( 1 ) ;
126
- expect ( result [ 0 ] . endPosition . row ) . to . equal ( 10 ) ;
127
- expect ( result [ 0 ] . children . length ) . to . equal ( 1 ) ;
128
- expect ( result [ 0 ] . children [ 0 ] . endPosition . row ) . to . equal ( 7 ) ;
127
+
128
+ const outline = result [ 0 ] ;
129
+ expect ( outline . endPosition ) . to . not . be . undefined ;
130
+ if ( outline . endPosition ) {
131
+ expect ( outline . endPosition . row ) . to . equal ( 10 ) ;
132
+ expect ( outline . children . length ) . to . equal ( 1 ) ;
133
+
134
+ const outlineChild = outline . children [ 0 ] ;
135
+ expect ( outlineChild . endPosition ) . to . not . be . undefined ;
136
+ if ( outlineChild . endPosition ) {
137
+ expect ( outlineChild . endPosition . row ) . to . equal ( 7 ) ;
138
+ }
139
+ }
129
140
} ) ;
130
141
131
142
it ( 'parents to the innnermost named container' , ( ) => {
@@ -141,11 +152,29 @@ describe('OutlineViewAdapter', () => {
141
152
] ;
142
153
const result = OutlineViewAdapter . createOutlineTrees ( sourceItems ) ;
143
154
expect ( result . length ) . to . equal ( 1 ) ;
144
- expect ( result [ 0 ] . endPosition . row ) . to . equal ( 10 ) ;
145
- expect ( result [ 0 ] . children . length ) . to . equal ( 1 ) ;
146
- expect ( result [ 0 ] . children [ 0 ] . endPosition . row ) . to . equal ( 8 ) ;
147
- expect ( result [ 0 ] . children [ 0 ] . children . length ) . to . equal ( 1 ) ;
148
- expect ( result [ 0 ] . children [ 0 ] . children [ 0 ] . endPosition . row ) . to . equal ( 5 ) ;
155
+
156
+ const outline = result [ 0 ] ;
157
+ expect ( outline ) . to . not . be . undefined ;
158
+ if ( outline ) {
159
+ expect ( outline . endPosition ) . to . not . be . undefined ;
160
+ if ( outline . endPosition ) {
161
+ expect ( outline . endPosition . row ) . to . equal ( 10 ) ;
162
+ expect ( outline . children . length ) . to . equal ( 1 ) ;
163
+
164
+ const outlineChild = outline . children [ 0 ] ;
165
+ expect ( outlineChild . endPosition ) . to . not . be . undefined ;
166
+ if ( outlineChild . endPosition ) {
167
+ expect ( outlineChild . endPosition . row ) . to . equal ( 8 ) ;
168
+ expect ( outlineChild . children . length ) . to . equal ( 1 ) ;
169
+
170
+ const outlineGrandChild = outlineChild . children [ 0 ] ;
171
+ expect ( outlineGrandChild . endPosition ) . to . not . be . undefined ;
172
+ if ( outlineGrandChild . endPosition ) {
173
+ expect ( outlineGrandChild . endPosition . row ) . to . equal ( 5 ) ;
174
+ }
175
+ }
176
+ }
177
+ }
149
178
} ) ;
150
179
} ) ;
151
180
@@ -156,12 +185,19 @@ describe('OutlineViewAdapter', () => {
156
185
expect ( result . icon ) . to . equal ( 'type-class' ) ;
157
186
expect ( result . representativeName ) . to . equal ( 'Program' ) ;
158
187
expect ( result . children ) . to . deep . equal ( [ ] ) ;
159
- expect ( result . tokenizedText [ 0 ] . kind ) . to . equal ( 'type' ) ;
160
- expect ( result . tokenizedText [ 0 ] . value ) . to . equal ( 'Program' ) ;
161
- expect ( result . startPosition . row ) . to . equal ( 1 ) ;
162
- expect ( result . startPosition . column ) . to . equal ( 2 ) ;
163
- expect ( result . endPosition . row ) . to . equal ( 3 ) ;
164
- expect ( result . endPosition . column ) . to . equal ( 4 ) ;
188
+ expect ( result . tokenizedText ) . to . not . be . undefined ;
189
+ if ( result . tokenizedText ) {
190
+ const resultTokenixedText = result . tokenizedText [ 0 ] ;
191
+ expect ( result . tokenizedText [ 0 ] . kind ) . to . equal ( 'type' ) ;
192
+ expect ( result . tokenizedText [ 0 ] . value ) . to . equal ( 'Program' ) ;
193
+ expect ( result . startPosition . row ) . to . equal ( 1 ) ;
194
+ expect ( result . startPosition . column ) . to . equal ( 2 ) ;
195
+ expect ( result . endPosition ) . to . not . be . undefined ;
196
+ if ( result . endPosition ) {
197
+ expect ( result . endPosition . row ) . to . equal ( 3 ) ;
198
+ expect ( result . endPosition . column ) . to . equal ( 4 ) ;
199
+ }
200
+ }
165
201
} ) ;
166
202
} ) ;
167
203
} ) ;
0 commit comments