From 24b003992a308deddec56a1be4bc28352532f6cc Mon Sep 17 00:00:00 2001 From: Connor Lanigan Date: Wed, 19 Jul 2023 17:39:25 +0000 Subject: [PATCH] Update test --- .../utils/__tests__/node-belongs.test.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/internal/utils/__tests__/node-belongs.test.ts b/src/internal/utils/__tests__/node-belongs.test.ts index 31f8f99e99..24969d02c0 100644 --- a/src/internal/utils/__tests__/node-belongs.test.ts +++ b/src/internal/utils/__tests__/node-belongs.test.ts @@ -3,8 +3,16 @@ import { nodeBelongs } from '../../../../lib/components/internal/utils/node-belongs'; describe('nodeBelongs', () => { + let div: HTMLDivElement; + + beforeEach(() => { + div = document.createElement('div'); + document.documentElement.appendChild(div); + }); + + afterEach(() => document.documentElement.removeChild(div)); + test('returns "true", when the node and the container are the same element', () => { - const div = document.createElement('div'); div.innerHTML = `
`; @@ -12,7 +20,6 @@ describe('nodeBelongs', () => { }); test('returns "true", when the node is descendant from the container', () => { - const div = document.createElement('div'); div.innerHTML = `
@@ -22,7 +29,6 @@ describe('nodeBelongs', () => { }); test('returns "false", when the node is not a child of the container', () => { - const div = document.createElement('div'); div.innerHTML = `
@@ -31,7 +37,6 @@ describe('nodeBelongs', () => { }); test('returns "true" when node belongs to a portal issued from within the container', () => { - const div = document.createElement('div'); div.innerHTML = `
@@ -40,12 +45,6 @@ describe('nodeBelongs', () => {
`; - document.documentElement.appendChild(div); - - try { - expect(nodeBelongs(div.querySelector('#container1'), div.querySelector('#node') as Node)).toBe(true); - } finally { - document.documentElement.removeChild(div); - } + expect(nodeBelongs(div.querySelector('#container1'), div.querySelector('#node') as Node)).toBe(true); }); });