@@ -171,17 +171,18 @@ describe('findComponent', () => {
171
171
expect ( wrapper . findComponent ( Hello ) . unmount ) . toThrowError ( )
172
172
} )
173
173
174
- it ( 'finds nested componens' , ( ) => {
175
- // https://github.com/vuejs/vue-test-utils-next/issues/173
176
- const ComponentA = {
177
- name : 'ComponentA' ,
178
- template : `<div><slot></slot></div>`
179
- }
180
-
181
- const ComponentB = {
182
- name : 'ComponentB' ,
183
- template : '<div><slot></slot></div>'
184
- }
174
+ // https://github.com/vuejs/vue-test-utils-next/issues/173
175
+ const ComponentA = {
176
+ name : 'ComponentA' ,
177
+ template : `<div><slot></slot></div>`
178
+ }
179
+
180
+ const ComponentB = {
181
+ name : 'ComponentB' ,
182
+ template : '<div><slot></slot></div>'
183
+ }
184
+
185
+ it ( 'finds nested components and obtains expected html and innerText' , ( ) => {
185
186
const wrapper = mount ( {
186
187
components : {
187
188
ComponentA,
@@ -198,4 +199,31 @@ describe('findComponent', () => {
198
199
const com1 = wrapper . findComponent ( ComponentB )
199
200
expect ( com1 . html ( ) ) . toBe ( '<div>1</div>' )
200
201
} )
202
+
203
+ it ( 'finds nested components and obtains expected html and innerText' , ( ) => {
204
+ const wrapper = mount ( {
205
+ components : {
206
+ ComponentA,
207
+ ComponentB
208
+ } ,
209
+ template : `
210
+ <ComponentA>
211
+ <ComponentB>
212
+ <div class="content" id="1">1</div>
213
+ </ComponentB>
214
+ <ComponentB>
215
+ <div class="content" id="2">2</div>
216
+ </ComponentB>
217
+ <ComponentB>
218
+ <div class="content" id="3">3</div>
219
+ </ComponentB>
220
+ </ComponentA>
221
+ `
222
+ } )
223
+
224
+ const compB = wrapper . findAllComponents ( ComponentB )
225
+ expect ( compB [ 0 ] . find ( '.content' ) . text ( ) ) . toBe ( '1' )
226
+ expect ( compB [ 0 ] . vm . $el . querySelector ( '.content' ) . innerHTML ) . toBe ( '1' )
227
+ expect ( compB [ 0 ] . vm . $el . querySelector ( '.content' ) . textContent ) . toBe ( '1' )
228
+ } )
201
229
} )
0 commit comments