diff --git a/tests/cases/applyReactInVue/1-test.js b/tests/cases/applyReactInVue/1-test.js index d0453a9..3b5edc1 100644 --- a/tests/cases/applyReactInVue/1-test.js +++ b/tests/cases/applyReactInVue/1-test.js @@ -5,20 +5,16 @@ import LazyReactInVue from './LazyReactInVue' // function Basic() { // return h('div', null, 121212) // } -test('renders a React component In Vue', (done) => { +test('renders a React component In Vue', async () => { render(Basic); - setTimeout(() => { - const linkElement = screen.getByText(/React in Vue/); - expect(linkElement).toBeInTheDocument(); - done() - }) + const linkElement = await screen.findByText(/React in Vue/); + expect(linkElement).toBeInTheDocument(); }); -test('test lazyReactInVue', (done) => { +test('test lazyReactInVue', async () => { render(LazyReactInVue); - setTimeout(() => { - const linkElement = screen.getByText(/test lazyReactInVue/); - expect(linkElement).toBeInTheDocument(); - done() - }) + let linkElement = await screen.findByText(/test lazyReactInVue/); + expect(linkElement).toBeInTheDocument(); + linkElement = await screen.findByText(/test lazyPureReactInVue/); + expect(linkElement).toBeInTheDocument(); }) diff --git a/tests/cases/applyReactInVue/2-scopedSlots-vnode-test.js b/tests/cases/applyReactInVue/2-scopedSlots-vnode-test.js index f741b29..fbaf5e6 100644 --- a/tests/cases/applyReactInVue/2-scopedSlots-vnode-test.js +++ b/tests/cases/applyReactInVue/2-scopedSlots-vnode-test.js @@ -3,15 +3,12 @@ import React from 'react'; import { render, screen } from '@testing-library/vue'; import Event from "./2-scopedSlot-vnode" -test('test scoped slots', (done) => { +test('test scoped slots', async () => { render(Event); - setTimeout(() => { - const linkElement = screen.getByText(/vnode-/); - expect(linkElement).toBeInTheDocument() - const linkElement1 = screen.getByText(/scopedSlotA-attr1/); - expect(linkElement1).toBeInTheDocument() - const linkElement2 = screen.getByText(/slotA/); - expect(linkElement2).toBeInTheDocument() - done() - }); + const linkElement = await screen.findByText(/vnode-/); + expect(linkElement).toBeInTheDocument() + const linkElement1 = await screen.findByText(/scopedSlotA-attr1/); + expect(linkElement1).toBeInTheDocument() + const linkElement2 = await screen.findByText(/slotA/); + expect(linkElement2).toBeInTheDocument() }); diff --git a/tests/cases/applyReactInVue/3-getReactNode-test.js b/tests/cases/applyReactInVue/3-getReactNode-test.js index 36a5603..9f55eb3 100644 --- a/tests/cases/applyReactInVue/3-getReactNode-test.js +++ b/tests/cases/applyReactInVue/3-getReactNode-test.js @@ -2,12 +2,8 @@ import '@testing-library/jest-dom'; import { render, screen } from '@testing-library/vue'; import VueComponent from './3-getReactNode'; -test('test getReactNode', (done) => { +test('test getReactNode', async () => { render(VueComponent); - setTimeout(() => { - const linkElement = screen.getByText(/test getReactNode/); - expect(linkElement).toBeInTheDocument(); - done() - }) - + const linkElement = await screen.findByText(/test getReactNode/); + expect(linkElement).toBeInTheDocument(); }); diff --git a/tests/cases/applyReactInVue/LazyReactInVue.vue b/tests/cases/applyReactInVue/LazyReactInVue.vue index 03366f4..1d87fb1 100644 --- a/tests/cases/applyReactInVue/LazyReactInVue.vue +++ b/tests/cases/applyReactInVue/LazyReactInVue.vue @@ -1,10 +1,17 @@ diff --git a/tests/cases/applyVueInReact/1-test.js b/tests/cases/applyVueInReact/1-test.js index 00e0d78..463f89d 100644 --- a/tests/cases/applyVueInReact/1-test.js +++ b/tests/cases/applyVueInReact/1-test.js @@ -2,7 +2,7 @@ import '@testing-library/jest-dom'; import { render, screen, act } from '@testing-library/react'; import React from 'react'; import Basic from './Basic'; -import {lazyVueInReact} from 'veaury' +import {lazyVueInReact, lazyPureVueInReact} from 'veaury' test('renders a Vue component in React', () => { render(); @@ -11,13 +11,18 @@ test('renders a Vue component in React', () => { }); -test('test lazyVueInReact', (done) => { +test('test lazyVueInReact', async () => { const VueComponentInReact = lazyVueInReact(() => import('./VueComponent')) - act(async () => { - render(test lazyVueInReact) - }).then(() => { - const linkElement = screen.getByText(/test lazyVueInReact/); - expect(linkElement).toBeInTheDocument(); - done() + const PureVueComponentInReact = lazyPureVueInReact(() => import('./VueComponent')) + await act(async () => { + render(
+ test lazyVueInReact + test lazyPureVueInReact +
) }) + + let linkElement = await screen.findByText(/test lazyVueInReact/); + expect(linkElement).toBeInTheDocument(); + linkElement = await screen.findByText(/test lazyPureVueInReact/); + expect(linkElement).toBeInTheDocument(); }) diff --git a/tests/cases/applyVueInReact/3-globalVueComponent-test.js b/tests/cases/applyVueInReact/3-globalVueComponent-test.js index 69d54c0..6becdf3 100644 --- a/tests/cases/applyVueInReact/3-globalVueComponent-test.js +++ b/tests/cases/applyVueInReact/3-globalVueComponent-test.js @@ -12,13 +12,10 @@ const ReactComponent = applyVueInReact(VueFC, {beforeVueAppMount(app) { app.component('GlobalVueComponent', VueComponent) }}) const ReactNode =
test getVNode
-test('test global vue component', (done) => { +test('test global vue component', async () => { render( ); - setTimeout(() => { - const linkElement = screen.getByText(/test global vue component/); - expect(linkElement).toBeInTheDocument(); - done() - }) + const linkElement = await screen.findByText(/test global vue component/); + expect(linkElement).toBeInTheDocument(); });