test: fix test case broken by b93f264

This commit is contained in:
Evan You 2024-04-22 21:05:00 +08:00
parent b93f264647
commit a7cf74277e
No known key found for this signature in database
GPG Key ID: B9D421896CA450FB
2 changed files with 12 additions and 7 deletions

View File

@ -11,15 +11,17 @@ import {
getCurrentInstance,
h,
inject,
nextTick,
nodeOps,
provide,
ref,
render,
serializeInner,
toRaw,
toRefs,
watch,
} from '@vue/runtime-test'
import { render as domRender, nextTick } from 'vue'
import { render as domRender } from 'vue'
describe('component props', () => {
test('stateful', () => {
@ -127,12 +129,12 @@ describe('component props', () => {
render(h(Comp, { foo: 1 }), root)
expect(props).toEqual({ foo: 1 })
expect(attrs).toEqual({ foo: 1 })
expect(props).toBe(attrs)
expect(toRaw(props)).toBe(attrs)
render(h(Comp, { bar: 2 }), root)
expect(props).toEqual({ bar: 2 })
expect(attrs).toEqual({ bar: 2 })
expect(props).toBe(attrs)
expect(toRaw(props)).toBe(attrs)
})
test('boolean casting', () => {

View File

@ -55,12 +55,12 @@ export function renderComponentRoot(
emit,
render,
renderCache,
props,
data,
setupState,
ctx,
inheritAttrs,
} = instance
const props = __DEV__ ? shallowReadonly(instance.props) : instance.props
const prev = setCurrentRenderingInstance(instance)
let result
@ -94,7 +94,7 @@ export function renderComponentRoot(
thisProxy,
proxyToUse!,
renderCache,
props,
__DEV__ ? shallowReadonly(props) : props,
setupState,
data,
ctx,
@ -111,7 +111,7 @@ export function renderComponentRoot(
result = normalizeVNode(
render.length > 1
? render(
props,
__DEV__ ? shallowReadonly(props) : props,
__DEV__
? {
get attrs() {
@ -123,7 +123,10 @@ export function renderComponentRoot(
}
: { attrs, slots, emit },
)
: render(props, null as any /* we know it doesn't need it */),
: render(
__DEV__ ? shallowReadonly(props) : props,
null as any /* we know it doesn't need it */,
),
)
fallthroughAttrs = Component.props
? attrs