Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
h,
createApp,
defineComponent,
reactive,
shallowReactive,
FunctionalComponent,
ComponentPublicInstance,
ComponentOptionsWithObjectProps,
Expand Down Expand Up @@ -379,7 +379,7 @@ export function mount(
const MOUNT_COMPONENT_REF = 'VTU_COMPONENT'
// we define props as reactive so that way when we update them with `setProps`
// Vue's reactivity system will cause a rerender.
const props = reactive({
const props = shallowReactive({
...options?.attrs,
...options?.propsData,
...options?.props,
Expand Down
27 changes: 26 additions & 1 deletion tests/props.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mount, shallowMount } from '../src'
import WithProps from './components/WithProps.vue'
import PropWithSymbol from './components/PropWithSymbol.vue'
import Hello from './components/Hello.vue'
import { defineComponent, h } from 'vue'
import { defineComponent, h, isRef, ref } from 'vue'
import Title from './components/FunctionComponent'

describe('props', () => {
Expand Down Expand Up @@ -157,6 +157,31 @@ describe('props', () => {
expect(wrapper.find('#foo2').attributes().foo).toBe('foo2 value')
})

it('should forward ref as raw prop', () => {
const TestComponent = defineComponent({
props: {
refProp: {
type: [Object],
required: true
}
},
setup(props) {
return () =>
h('div', [
h('h1', isRef(props.refProp) ? 'is ref' : 'is not ref'),
h('span', props.refProp.value)
])
}
})

const refProp = ref('Some value')
const wrapper = mount(TestComponent, {
props: { refProp }
})
expect(wrapper.find('h1').text()).toBe('is ref')
expect(wrapper.find('span').text()).toBe('Some value')
})

it('returns reactive props on a stubbed component shallow case', async () => {
const Foo = {
name: 'Foo',
Expand Down