From 45ce289aa4343a1b6d733164209a9c8a5eddfa1a Mon Sep 17 00:00:00 2001 From: taku-y-9308 Date: Fri, 22 Mar 2024 09:35:38 +0900 Subject: [PATCH] test: add tests for attaching to SVGElement --- tests/mountingOptions/attachTo.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/mountingOptions/attachTo.spec.ts b/tests/mountingOptions/attachTo.spec.ts index d499df86b..6ceba75bd 100644 --- a/tests/mountingOptions/attachTo.spec.ts +++ b/tests/mountingOptions/attachTo.spec.ts @@ -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'