Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 465676f

Browse files
committed
chore: Replace vue-portal with teleport
1 parent 62e9b45 commit 465676f

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

‎package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"jest-serializer-vue": "^2.0.2",
7070
"kcd-scripts": "^7.5.1",
7171
"msw": "^0.21.3",
72-
"portal-vue": "^2.1.7",
7372
"typescript": "^4.1.2",
7473
"vee-validate": "^4.0.2",
7574
"vue": "^3.0.4",

‎src/__tests__/teleport.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {defineComponent} from 'vue'
2+
import '@testing-library/jest-dom/extend-expect'
3+
import {render, fireEvent} from '..'
4+
5+
const ModalButton = defineComponent({
6+
data() {
7+
return {
8+
modalOpen: false,
9+
}
10+
},
11+
12+
template: `
13+
<button @click="modalOpen = true">open</button>
14+
15+
<teleport to="body">
16+
<div v-if="modalOpen" data-testid="teleported-modal">
17+
This is a teleported modal!
18+
<button @click="modalOpen = false">close</button>
19+
</div>
20+
</teleport>
21+
`,
22+
})
23+
24+
test('Teleport', async () => {
25+
const {queryByText, getByText} = render(ModalButton)
26+
27+
expect(queryByText('This is a teleported modal!')).not.toBeInTheDocument()
28+
29+
// Open the modal
30+
await fireEvent.click(getByText('open'))
31+
32+
const modal = getByText('This is a teleported modal!')
33+
34+
expect(modal).toBeInTheDocument()
35+
expect(modal.parentNode.nodeName).toBe('BODY')
36+
37+
// Close the modal
38+
await fireEvent.click(getByText('close'))
39+
40+
expect(queryByText('This is a teleported modal!')).not.toBeInTheDocument()
41+
})

‎src/__tests__/vue-portal.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /