From bf013cc33574d8379e4b8f71088d445b891cd261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Zugmeyer?= Date: Thu, 26 Jan 2023 17:25:12 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20fix=20Jasmine=20deprecation=20warni?= =?UTF-8?q?ng=20on=20unit=20tests/IE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "DEPRECATION: describe with no children (describe() or it()) is deprecated and will be removed in a future version of Jasmine." --- .../rum-core/src/browser/htmlDomUtils.spec.ts | 107 +++++++++--------- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/packages/rum-core/src/browser/htmlDomUtils.spec.ts b/packages/rum-core/src/browser/htmlDomUtils.spec.ts index 09a1fc6893..7ecf0b3c8d 100644 --- a/packages/rum-core/src/browser/htmlDomUtils.spec.ts +++ b/packages/rum-core/src/browser/htmlDomUtils.spec.ts @@ -57,48 +57,45 @@ describe('isElementNode', () => { }) }) -describe('isShadowRoot', () => { - if (isIE()) { - return - } - - const parent = document.createElement('div') - parent.attachShadow({ mode: 'open' }) - const parameters: Array<[Node, boolean]> = [ - [parent.shadowRoot!, true], - [parent, false], - [document.body, false], - [document.createTextNode('hello'), false], - [document.createComment('hello'), false], - ] +if (!isIE()) { + describe('isShadowRoot', () => { + const parent = document.createElement('div') + parent.attachShadow({ mode: 'open' }) + const parameters: Array<[Node, boolean]> = [ + [parent.shadowRoot!, true], + [parent, false], + [document.body, false], + [document.createTextNode('hello'), false], + [document.createComment('hello'), false], + ] - parameters.forEach(([element, result]) => { - it(`should return ${String(result)} for "${String(element)}"`, () => { - expect(isNodeShadowRoot(element)).toBe(result) + parameters.forEach(([element, result]) => { + it(`should return ${String(result)} for "${String(element)}"`, () => { + expect(isNodeShadowRoot(element)).toBe(result) + }) }) }) -}) - -describe('isShadowHost', () => { - if (isIE()) { - return - } - const host = document.createElement('div') - host.attachShadow({ mode: 'open' }) - const parameters: Array<[Node, boolean]> = [ - [host, true], - [host.shadowRoot!, false], - [document.body, false], - [document.createTextNode('hello'), false], - [document.createComment('hello'), false], - ] +} + +if (!isIE()) { + describe('isShadowHost', () => { + const host = document.createElement('div') + host.attachShadow({ mode: 'open' }) + const parameters: Array<[Node, boolean]> = [ + [host, true], + [host.shadowRoot!, false], + [document.body, false], + [document.createTextNode('hello'), false], + [document.createComment('hello'), false], + ] - parameters.forEach(([element, result]) => { - it(`should return ${String(result)} for "${String(element)}"`, () => { - expect(isNodeShadowHost(element)).toBe(result) + parameters.forEach(([element, result]) => { + it(`should return ${String(result)} for "${String(element)}"`, () => { + expect(isNodeShadowHost(element)).toBe(result) + }) }) }) -}) +} describe('getChildNodes', () => { it('should return the direct children for a normal node', () => { @@ -140,27 +137,25 @@ describe('getChildNodes', () => { }) }) -describe('getParentNode', () => { - if (isIE()) { - return - } - - const orphanDiv = document.createElement('div') - const parentWithShadowRoot = document.createElement('div') - const shadowRoot = parentWithShadowRoot.attachShadow({ mode: 'open' }) +if (!isIE()) { + describe('getParentNode', () => { + const orphanDiv = document.createElement('div') + const parentWithShadowRoot = document.createElement('div') + const shadowRoot = parentWithShadowRoot.attachShadow({ mode: 'open' }) - const parentWithoutShadowRoot = document.createElement('div') - const child = document.createElement('span') - parentWithoutShadowRoot.appendChild(child) + const parentWithoutShadowRoot = document.createElement('div') + const child = document.createElement('span') + parentWithoutShadowRoot.appendChild(child) - const parameters: Array<[string, Node, Node | null]> = [ - ['return null if without parent', orphanDiv, null], - ['return the host for a shadow root', shadowRoot, parentWithShadowRoot], - ['return the parent for normal child', child, parentWithoutShadowRoot], - ] - parameters.forEach(([label, element, result]) => { - it(`should ${label}`, () => { - expect(getParentNode(element)).toBe(result) + const parameters: Array<[string, Node, Node | null]> = [ + ['return null if without parent', orphanDiv, null], + ['return the host for a shadow root', shadowRoot, parentWithShadowRoot], + ['return the parent for normal child', child, parentWithoutShadowRoot], + ] + parameters.forEach(([label, element, result]) => { + it(`should ${label}`, () => { + expect(getParentNode(element)).toBe(result) + }) }) }) -}) +}