/
suspense.spec.js
45 lines (39 loc) · 1.11 KB
/
suspense.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { h, defineComponent, Suspense } from 'vue';
import { renderAsync } from './renderAsync';
import { render } from '@testing-library/vue';
it("renders a async component with a sync render function", async () => {
const Component = defineComponent({
async setup() {
return () => h("div", "AsyncSetup");
},
});
const { queryByText } = render(
defineComponent({
render() {
return h(Suspense, null, {
default: h(Component),
fallback: h("div", "fallback"),
});
},
})
);
expect(queryByText("AsyncSetup")).not.toBeInTheDocument();
});
it("renders a async component with a async render function", async () => {
const Component = defineComponent({
async setup() {
return () => h("div", "AsyncSetup");
},
});
const { getByText } = await renderAsync(
defineComponent({
render() {
return h(Suspense, null, {
default: h(Component),
fallback: h("div", "fallback"),
});
},
})
);
expect(getByText("AsyncSetup")).toBeInTheDocument();
});