Skip to content

Commit ad3d8fa

Browse files
authored
test(runtime-vapor): fix type (#229)
1 parent a1797f8 commit ad3d8fa

File tree

7 files changed

+11
-21
lines changed

7 files changed

+11
-21
lines changed

packages/runtime-vapor/__tests__/componentAttrs.spec.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
template,
88
watchEffect,
99
} from '../src'
10-
import { setCurrentInstance } from '../src/component'
1110
import { makeRender } from './_utils'
1211

1312
const define = makeRender<any>()
@@ -27,7 +26,7 @@ describe('attribute fallthrough', () => {
2726

2827
const foo = ref(1)
2928
const id = ref('a')
30-
const { instance, host } = define({
29+
const { host } = define({
3130
setup() {
3231
return { foo, id }
3332
},
@@ -46,7 +45,6 @@ describe('attribute fallthrough', () => {
4645
)
4746
},
4847
}).render()
49-
const reset = setCurrentInstance(instance)
5048
expect(host.innerHTML).toBe('<div id="a">1</div>')
5149

5250
foo.value++
@@ -56,7 +54,6 @@ describe('attribute fallthrough', () => {
5654
id.value = 'b'
5755
await nextTick()
5856
expect(host.innerHTML).toBe('<div id="b">2</div>')
59-
reset()
6057
})
6158

6259
it('should not fallthrough if explicitly pass inheritAttrs: false', async () => {
@@ -74,7 +71,7 @@ describe('attribute fallthrough', () => {
7471

7572
const foo = ref(1)
7673
const id = ref('a')
77-
const { instance, host } = define({
74+
const { host } = define({
7875
setup() {
7976
return { foo, id }
8077
},
@@ -93,7 +90,6 @@ describe('attribute fallthrough', () => {
9390
)
9491
},
9592
}).render()
96-
const reset = setCurrentInstance(instance)
9793
expect(host.innerHTML).toBe('<div>1</div>')
9894

9995
foo.value++
@@ -103,7 +99,6 @@ describe('attribute fallthrough', () => {
10399
id.value = 'b'
104100
await nextTick()
105101
expect(host.innerHTML).toBe('<div>2</div>')
106-
reset()
107102
})
108103

109104
it('should pass through attrs in nested single root components', async () => {
@@ -137,7 +132,7 @@ describe('attribute fallthrough', () => {
137132

138133
const foo = ref(1)
139134
const id = ref('a')
140-
const { instance, host } = define({
135+
const { host } = define({
141136
setup() {
142137
return { foo, id }
143138
},
@@ -156,7 +151,6 @@ describe('attribute fallthrough', () => {
156151
)
157152
},
158153
}).render()
159-
const reset = setCurrentInstance(instance)
160154
expect(host.innerHTML).toBe('<div foo="1" id="a">1</div>')
161155

162156
foo.value++
@@ -166,6 +160,5 @@ describe('attribute fallthrough', () => {
166160
id.value = 'b'
167161
await nextTick()
168162
expect(host.innerHTML).toBe('<div foo="2" id="b">2</div>')
169-
reset()
170163
})
171164
})

packages/runtime-vapor/__tests__/componentExpose.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('component expose', () => {
1313
},
1414
})
1515
const { instance } = render()
16-
expect(instance.exposed).toEqual(expxosedObj)
16+
expect(instance?.exposed).toEqual(expxosedObj)
1717
})
1818

1919
test('should warn when called multiple times', async () => {

packages/runtime-vapor/__tests__/componentProps.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// NOTE: This test is implemented based on the case of `runtime-core/__test__/componentProps.spec.ts`.
22

3-
import { setCurrentInstance } from '../src/component'
43
import {
54
createComponent,
65
defineComponent,
@@ -233,7 +232,7 @@ describe('component: props', () => {
233232

234233
const foo = ref(1)
235234
const id = ref('a')
236-
const { instance, host } = define({
235+
const { host } = define({
237236
setup() {
238237
return { foo, id }
239238
},
@@ -250,7 +249,6 @@ describe('component: props', () => {
250249
)
251250
},
252251
}).render()
253-
const reset = setCurrentInstance(instance)
254252
expect(host.innerHTML).toBe('<div id="a">1</div>')
255253

256254
foo.value++
@@ -260,7 +258,6 @@ describe('component: props', () => {
260258
id.value = 'b'
261259
await nextTick()
262260
expect(host.innerHTML).toBe('<div id="b">2</div>')
263-
reset()
264261
})
265262

266263
describe('validator', () => {

packages/runtime-vapor/__tests__/directives/vShow.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('directive: v-show', () => {
7777
}).render()
7878

7979
expect(host.innerHTML).toBe('<button>toggle</button><div>child</div>')
80-
expect(instance.scope.dirs!.get(n0)![0].dir).toBe(vShow)
80+
expect(instance?.scope.dirs!.get(n0)![0].dir).toBe(vShow)
8181

8282
const btn = host.querySelector('button')
8383
btn?.click()

packages/runtime-vapor/__tests__/for.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ describe('createFor', () => {
305305
calls.length = 0
306306
expect(spySrcFn).toHaveBeenCalledTimes(7)
307307

308-
unmountComponent(instance)
308+
unmountComponent(instance!)
309309
expect(calls).toEqual(['0 beforeUnmount', '0 unmounted'])
310310
expect(spySrcFn).toHaveBeenCalledTimes(7)
311311
})

packages/runtime-vapor/__tests__/if.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ describe('createIf', () => {
237237
expect(spyConditionFn1).toHaveBeenCalledTimes(3)
238238
expect(spyConditionFn2).toHaveBeenCalledTimes(2)
239239

240-
unmountComponent(instance)
240+
unmountComponent(instance!)
241241
expect(calls).toEqual(['1 beforeUnmount', '1 unmounted'])
242242
expect(spyConditionFn1).toHaveBeenCalledTimes(3)
243243
expect(spyConditionFn2).toHaveBeenCalledTimes(2)

packages/runtime-vapor/__tests__/renderEffect.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('renderEffect', () => {
110110
})
111111
},
112112
).render()
113-
const { change, changeRender } = instance.setupState as any
113+
const { change, changeRender } = instance?.setupState as any
114114

115115
expect(calls).toEqual(['pre 0', 'sync 0', 'renderEffect 0', 'post 0'])
116116
calls.length = 0
@@ -173,7 +173,7 @@ describe('renderEffect', () => {
173173
})
174174
},
175175
).render()
176-
const { update } = instance.setupState as any
176+
const { update } = instance?.setupState as any
177177
await expect(async () => {
178178
update()
179179
await nextTick()
@@ -203,7 +203,7 @@ describe('renderEffect', () => {
203203
},
204204
).render()
205205

206-
const { update } = instance.setupState as any
206+
const { update } = instance?.setupState as any
207207
await expect(async () => {
208208
update()
209209
await nextTick()

0 commit comments

Comments
 (0)