1
1
import { defineComponent } from 'vue'
2
- import { mount , MountingOptions , RouterLinkStub , shallowMount } from '../src'
2
+ import { mount , RouterLinkStub , shallowMount } from '../src'
3
3
import Issue425 from './components/Issue425.vue'
4
4
5
5
const compA = defineComponent ( {
@@ -15,14 +15,15 @@ describe('getComponent', () => {
15
15
it ( 'should delegate to findComponent' , ( ) => {
16
16
const wrapper = mount ( compA )
17
17
jest . spyOn ( wrapper , 'findComponent' ) . mockReturnThis ( )
18
- wrapper . getComponent ( '.domElement' )
19
- expect ( wrapper . findComponent ) . toHaveBeenCalledWith ( '.domElement' )
18
+ wrapper . getComponent ( compA )
19
+ expect ( wrapper . findComponent ) . toHaveBeenCalledWith ( compA )
20
20
} )
21
21
22
22
it ( 'should throw if not found with a string selector' , ( ) => {
23
23
const wrapper = mount ( compA )
24
+ // @ts -expect-error
24
25
expect ( ( ) => wrapper . getComponent ( '.domElement' ) ) . toThrowError (
25
- 'Unable to get component with selector .domElement within: <div class="A"></div> '
26
+ 'findComponent requires a Vue constructor or valid find object. If you are searching for DOM nodes, use `find` instead '
26
27
)
27
28
} )
28
29
@@ -69,12 +70,12 @@ describe('getComponent', () => {
69
70
// https://github.com/vuejs/vue-test-utils-next/issues/425
70
71
it ( 'works with router-link and mount' , ( ) => {
71
72
const wrapper = mount ( Issue425 , options )
72
- expect ( wrapper . getComponent ( '.link' ) . props ( 'to' ) ) . toEqual ( { name } )
73
+ expect ( wrapper . getComponent ( RouterLinkStub ) . props ( 'to' ) ) . toEqual ( { name } )
73
74
} )
74
75
75
76
// https://github.com/vuejs/vue-test-utils-next/issues/425
76
77
it ( 'works with router-link and shallowMount' , ( ) => {
77
78
const wrapper = shallowMount ( Issue425 , options )
78
- expect ( wrapper . getComponent ( '.link' ) . props ( 'to' ) ) . toEqual ( { name } )
79
+ expect ( wrapper . getComponent ( RouterLinkStub ) . props ( 'to' ) ) . toEqual ( { name } )
79
80
} )
80
81
} )
0 commit comments