mirror of https://github.com/vuejs/core.git
test(runtime-vapor): fix type (#229)
This commit is contained in:
parent
a1797f8861
commit
ad3d8fa6b4
|
@ -7,7 +7,6 @@ import {
|
|||
template,
|
||||
watchEffect,
|
||||
} from '../src'
|
||||
import { setCurrentInstance } from '../src/component'
|
||||
import { makeRender } from './_utils'
|
||||
|
||||
const define = makeRender<any>()
|
||||
|
@ -27,7 +26,7 @@ describe('attribute fallthrough', () => {
|
|||
|
||||
const foo = ref(1)
|
||||
const id = ref('a')
|
||||
const { instance, host } = define({
|
||||
const { host } = define({
|
||||
setup() {
|
||||
return { foo, id }
|
||||
},
|
||||
|
@ -46,7 +45,6 @@ describe('attribute fallthrough', () => {
|
|||
)
|
||||
},
|
||||
}).render()
|
||||
const reset = setCurrentInstance(instance)
|
||||
expect(host.innerHTML).toBe('<div id="a">1</div>')
|
||||
|
||||
foo.value++
|
||||
|
@ -56,7 +54,6 @@ describe('attribute fallthrough', () => {
|
|||
id.value = 'b'
|
||||
await nextTick()
|
||||
expect(host.innerHTML).toBe('<div id="b">2</div>')
|
||||
reset()
|
||||
})
|
||||
|
||||
it('should not fallthrough if explicitly pass inheritAttrs: false', async () => {
|
||||
|
@ -74,7 +71,7 @@ describe('attribute fallthrough', () => {
|
|||
|
||||
const foo = ref(1)
|
||||
const id = ref('a')
|
||||
const { instance, host } = define({
|
||||
const { host } = define({
|
||||
setup() {
|
||||
return { foo, id }
|
||||
},
|
||||
|
@ -93,7 +90,6 @@ describe('attribute fallthrough', () => {
|
|||
)
|
||||
},
|
||||
}).render()
|
||||
const reset = setCurrentInstance(instance)
|
||||
expect(host.innerHTML).toBe('<div>1</div>')
|
||||
|
||||
foo.value++
|
||||
|
@ -103,7 +99,6 @@ describe('attribute fallthrough', () => {
|
|||
id.value = 'b'
|
||||
await nextTick()
|
||||
expect(host.innerHTML).toBe('<div>2</div>')
|
||||
reset()
|
||||
})
|
||||
|
||||
it('should pass through attrs in nested single root components', async () => {
|
||||
|
@ -137,7 +132,7 @@ describe('attribute fallthrough', () => {
|
|||
|
||||
const foo = ref(1)
|
||||
const id = ref('a')
|
||||
const { instance, host } = define({
|
||||
const { host } = define({
|
||||
setup() {
|
||||
return { foo, id }
|
||||
},
|
||||
|
@ -156,7 +151,6 @@ describe('attribute fallthrough', () => {
|
|||
)
|
||||
},
|
||||
}).render()
|
||||
const reset = setCurrentInstance(instance)
|
||||
expect(host.innerHTML).toBe('<div foo="1" id="a">1</div>')
|
||||
|
||||
foo.value++
|
||||
|
@ -166,6 +160,5 @@ describe('attribute fallthrough', () => {
|
|||
id.value = 'b'
|
||||
await nextTick()
|
||||
expect(host.innerHTML).toBe('<div foo="2" id="b">2</div>')
|
||||
reset()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -13,7 +13,7 @@ describe('component expose', () => {
|
|||
},
|
||||
})
|
||||
const { instance } = render()
|
||||
expect(instance.exposed).toEqual(expxosedObj)
|
||||
expect(instance?.exposed).toEqual(expxosedObj)
|
||||
})
|
||||
|
||||
test('should warn when called multiple times', async () => {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// NOTE: This test is implemented based on the case of `runtime-core/__test__/componentProps.spec.ts`.
|
||||
|
||||
import { setCurrentInstance } from '../src/component'
|
||||
import {
|
||||
createComponent,
|
||||
defineComponent,
|
||||
|
@ -233,7 +232,7 @@ describe('component: props', () => {
|
|||
|
||||
const foo = ref(1)
|
||||
const id = ref('a')
|
||||
const { instance, host } = define({
|
||||
const { host } = define({
|
||||
setup() {
|
||||
return { foo, id }
|
||||
},
|
||||
|
@ -250,7 +249,6 @@ describe('component: props', () => {
|
|||
)
|
||||
},
|
||||
}).render()
|
||||
const reset = setCurrentInstance(instance)
|
||||
expect(host.innerHTML).toBe('<div id="a">1</div>')
|
||||
|
||||
foo.value++
|
||||
|
@ -260,7 +258,6 @@ describe('component: props', () => {
|
|||
id.value = 'b'
|
||||
await nextTick()
|
||||
expect(host.innerHTML).toBe('<div id="b">2</div>')
|
||||
reset()
|
||||
})
|
||||
|
||||
describe('validator', () => {
|
||||
|
|
|
@ -77,7 +77,7 @@ describe('directive: v-show', () => {
|
|||
}).render()
|
||||
|
||||
expect(host.innerHTML).toBe('<button>toggle</button><div>child</div>')
|
||||
expect(instance.scope.dirs!.get(n0)![0].dir).toBe(vShow)
|
||||
expect(instance?.scope.dirs!.get(n0)![0].dir).toBe(vShow)
|
||||
|
||||
const btn = host.querySelector('button')
|
||||
btn?.click()
|
||||
|
|
|
@ -305,7 +305,7 @@ describe('createFor', () => {
|
|||
calls.length = 0
|
||||
expect(spySrcFn).toHaveBeenCalledTimes(7)
|
||||
|
||||
unmountComponent(instance)
|
||||
unmountComponent(instance!)
|
||||
expect(calls).toEqual(['0 beforeUnmount', '0 unmounted'])
|
||||
expect(spySrcFn).toHaveBeenCalledTimes(7)
|
||||
})
|
||||
|
|
|
@ -237,7 +237,7 @@ describe('createIf', () => {
|
|||
expect(spyConditionFn1).toHaveBeenCalledTimes(3)
|
||||
expect(spyConditionFn2).toHaveBeenCalledTimes(2)
|
||||
|
||||
unmountComponent(instance)
|
||||
unmountComponent(instance!)
|
||||
expect(calls).toEqual(['1 beforeUnmount', '1 unmounted'])
|
||||
expect(spyConditionFn1).toHaveBeenCalledTimes(3)
|
||||
expect(spyConditionFn2).toHaveBeenCalledTimes(2)
|
||||
|
|
|
@ -110,7 +110,7 @@ describe('renderEffect', () => {
|
|||
})
|
||||
},
|
||||
).render()
|
||||
const { change, changeRender } = instance.setupState as any
|
||||
const { change, changeRender } = instance?.setupState as any
|
||||
|
||||
expect(calls).toEqual(['pre 0', 'sync 0', 'renderEffect 0', 'post 0'])
|
||||
calls.length = 0
|
||||
|
@ -173,7 +173,7 @@ describe('renderEffect', () => {
|
|||
})
|
||||
},
|
||||
).render()
|
||||
const { update } = instance.setupState as any
|
||||
const { update } = instance?.setupState as any
|
||||
await expect(async () => {
|
||||
update()
|
||||
await nextTick()
|
||||
|
@ -203,7 +203,7 @@ describe('renderEffect', () => {
|
|||
},
|
||||
).render()
|
||||
|
||||
const { update } = instance.setupState as any
|
||||
const { update } = instance?.setupState as any
|
||||
await expect(async () => {
|
||||
update()
|
||||
await nextTick()
|
||||
|
|
Loading…
Reference in New Issue