|
1 |
| -import { defineComponent } from 'vue' |
| 1 | +import { defineComponent, nextTick } from 'vue' |
2 | 2 | import { mount } from '../src'
|
3 | 3 | import Hello from './components/Hello.vue'
|
4 | 4 | import ComponentWithoutName from './components/ComponentWithoutName.vue'
|
@@ -112,6 +112,35 @@ describe('findComponent', () => {
|
112 | 112 | expect(wrapper.findComponent(compC).text()).toBe('C')
|
113 | 113 | })
|
114 | 114 |
|
| 115 | + it('finds component in a Suspense', async () => { |
| 116 | + const AsyncComponent = defineComponent({ |
| 117 | + template: '{{ result }}', |
| 118 | + async setup() { |
| 119 | + return { result: 'Hello world' } |
| 120 | + } |
| 121 | + }) |
| 122 | + const SuspenseComponent = defineComponent({ |
| 123 | + template: `<Suspense> |
| 124 | + <template #default><AsyncComponent/></template> |
| 125 | + <template #fallback><CompC/></template> |
| 126 | + </Suspense>`, |
| 127 | + components: { |
| 128 | + AsyncComponent, |
| 129 | + CompC: compC |
| 130 | + } |
| 131 | + }) |
| 132 | + const wrapper = mount(SuspenseComponent) |
| 133 | + expect(wrapper.html()).toContain('<div class="C">C</div>') |
| 134 | + expect(wrapper.findComponent(compC).exists()).toBe(true) |
| 135 | + expect(wrapper.findComponent(AsyncComponent).exists()).toBe(false) |
| 136 | + await nextTick() |
| 137 | + await nextTick() |
| 138 | + expect(wrapper.html()).toContain('Hello world') |
| 139 | + expect(wrapper.findComponent(compC).exists()).toBe(false) |
| 140 | + expect(wrapper.findComponent(AsyncComponent).exists()).toBe(true) |
| 141 | + expect(wrapper.findComponent(AsyncComponent).text()).toBe('Hello world') |
| 142 | + }) |
| 143 | + |
115 | 144 | it('finds a stub by name', () => {
|
116 | 145 | const wrapper = mount(compA, {
|
117 | 146 | global: {
|
|
0 commit comments