Skip to content

Commit

Permalink
馃殞馃殣馃殠馃殤馃殥馃殮
Browse files Browse the repository at this point in the history
  • Loading branch information
devilwjp committed Sep 1, 2022
1 parent fb26696 commit 4cc6603
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 47 deletions.
20 changes: 8 additions & 12 deletions tests/cases/applyReactInVue/1-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
})
17 changes: 7 additions & 10 deletions tests/cases/applyReactInVue/2-scopedSlots-vnode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});
10 changes: 3 additions & 7 deletions tests/cases/applyReactInVue/3-getReactNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
15 changes: 11 additions & 4 deletions tests/cases/applyReactInVue/LazyReactInVue.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<template>
<ReactComponent>
test lazyReactInVue
</ReactComponent>
<div>
<ReactComponent>
test lazyReactInVue
</ReactComponent>
<PureReactComponent>
test lazyPureReactInVue
</PureReactComponent>
</div>

</template>

<script setup>
import {lazyReactInVue} from 'veaury'
import {lazyReactInVue, lazyPureReactInVue} from 'veaury'
const ReactComponent = lazyReactInVue(() => import('./ReactComponent'))
const PureReactComponent = lazyPureReactInVue(() => import('./ReactComponent'))
</script>
21 changes: 13 additions & 8 deletions tests/cases/applyVueInReact/1-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(<Basic/>);
Expand All @@ -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(<VueComponentInReact>test lazyVueInReact</VueComponentInReact>)
}).then(() => {
const linkElement = screen.getByText(/test lazyVueInReact/);
expect(linkElement).toBeInTheDocument();
done()
const PureVueComponentInReact = lazyPureVueInReact(() => import('./VueComponent'))
await act(async () => {
render(<div>
<VueComponentInReact>test lazyVueInReact</VueComponentInReact>
<PureVueComponentInReact>test lazyPureVueInReact</PureVueComponentInReact>
</div>)
})

let linkElement = await screen.findByText(/test lazyVueInReact/);
expect(linkElement).toBeInTheDocument();
linkElement = await screen.findByText(/test lazyPureVueInReact/);
expect(linkElement).toBeInTheDocument();
})
9 changes: 3 additions & 6 deletions tests/cases/applyVueInReact/3-globalVueComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ const ReactComponent = applyVueInReact(VueFC, {beforeVueAppMount(app) {
app.component('GlobalVueComponent', VueComponent)
}})
const ReactNode = <div>test getVNode</div>
test('test global vue component', (done) => {
test('test global vue component', async () => {
render(<ReactComponent>
<VueContainer component={'GlobalVueComponent'}/>
</ReactComponent>);
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();
});

0 comments on commit 4cc6603

Please sign in to comment.