|
1 | 1 | import { describe, expect, it } from 'vitest' |
2 | | -import { mount, shallowMount } from '../src' |
| 2 | +import { mount, shallowMount, VueWrapper } from '../src' |
3 | 3 | import WithProps from './components/WithProps.vue' |
4 | 4 | import PropWithSymbol from './components/PropWithSymbol.vue' |
5 | 5 | import Hello from './components/Hello.vue' |
@@ -207,6 +207,31 @@ describe('props', () => { |
207 | 207 | expect(wrapper.find('.selectedField').text()).toBe('Cities') |
208 | 208 | }) |
209 | 209 |
|
| 210 | + it('returns props of stubbed root component', async () => { |
| 211 | + const ChildComponent = defineComponent({ |
| 212 | + props: { |
| 213 | + value: { |
| 214 | + type: Number, |
| 215 | + required: true |
| 216 | + } |
| 217 | + }, |
| 218 | + template: '<div>{{ value }}</div>' |
| 219 | + }) |
| 220 | + |
| 221 | + const TestComponent = defineComponent({ |
| 222 | + components: { ChildComponent }, |
| 223 | + template: '<ChildComponent :value="2"/>' |
| 224 | + }) |
| 225 | + |
| 226 | + const wrapper = shallowMount(TestComponent) |
| 227 | + expect( |
| 228 | + wrapper.findComponent({ name: 'ChildComponent' }).props() |
| 229 | + ).toStrictEqual({ value: 2 }) |
| 230 | + expect( |
| 231 | + (wrapper.findComponent('child-component-stub') as VueWrapper).props() |
| 232 | + ).toStrictEqual({ value: 2 }) |
| 233 | + }) |
| 234 | + |
210 | 235 | it('returns reactive props on a stubbed component shallow case', async () => { |
211 | 236 | const Foo = { |
212 | 237 | name: 'Foo', |
@@ -242,6 +267,7 @@ describe('props', () => { |
242 | 267 | foo: 'new value' |
243 | 268 | }) |
244 | 269 | }) |
| 270 | + |
245 | 271 | it('https://github.com/vuejs/test-utils/issues/440', async () => { |
246 | 272 | const Foo = defineComponent({ |
247 | 273 | name: 'Foo', |
|
0 commit comments