Skip to content

Commit

Permalink
test: add tests for attaching to SVGElement
Browse files Browse the repository at this point in the history
  • Loading branch information
taku-y-9308 committed Mar 22, 2024
1 parent f690543 commit 45ce289
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/mountingOptions/attachTo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ describe('options.attachTo', () => {
wrapper.unmount()
expect(document.getElementById('attach-to')).toBeNull()
})
it('attaches to a provided SVGElement', () => {
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
svg.id = 'root'
document.body.appendChild(svg)
expect(document.getElementById('root')).not.toBeNull()
expect(document.getElementById('attach-to')).toBeNull()
const wrapper = mount(TestComponent, {
attachTo: svg
})

const root = document.getElementById('root')
const rendered = document.getElementById('attach-to')!
expect(wrapper.vm.$el.parentNode).not.toBeNull()
expect(root).not.toBeNull()
expect(rendered).not.toBeNull()
expect(rendered.outerHTML).toBe(outerHTML)
wrapper.unmount()
expect(document.getElementById('attach-to')).toBeNull()
})
it('attaches to a provided CSS selector string', () => {
const div = document.createElement('div')
div.id = 'root'
Expand Down

0 comments on commit 45ce289

Please sign in to comment.