From b4e09b6257929356e1e148367c0a4bcdd650c68e Mon Sep 17 00:00:00 2001 From: konnorrogers Date: Mon, 14 Aug 2023 10:21:35 -0400 Subject: [PATCH 1/5] add stub code prior to test --- src/internal/shoelace-element.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/internal/shoelace-element.test.ts b/src/internal/shoelace-element.test.ts index 21fbf6cd32..15d18b9de8 100644 --- a/src/internal/shoelace-element.test.ts +++ b/src/internal/shoelace-element.test.ts @@ -133,6 +133,8 @@ before(async () => { relevantMetadata.forEach(({ tagName, path }) => { it(`Should not register any components: ${tagName}`, async () => { + Sinon.restore(); + stubCustomElements(); // Check if importing the files automatically registers any components await import('../../dist/' + path); From 568f2f81ffa359a6ae60f97d1680e27eea1f306f Mon Sep 17 00:00:00 2001 From: konnorrogers Date: Mon, 14 Aug 2023 10:45:11 -0400 Subject: [PATCH 2/5] fix broken test --- src/internal/shoelace-element.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/internal/shoelace-element.test.ts b/src/internal/shoelace-element.test.ts index 15d18b9de8..3538e517da 100644 --- a/src/internal/shoelace-element.test.ts +++ b/src/internal/shoelace-element.test.ts @@ -136,6 +136,8 @@ before(async () => { Sinon.restore(); stubCustomElements(); // Check if importing the files automatically registers any components + // this path comes through as "button.js" but we really need to test "button.component.js" + path = path.split(".js")[0] + ".component.js" await import('../../dist/' + path); const registeredTags = tagNames.filter(tag => Boolean(window.customElements.get(tag))); From 6600c52495787ce5570e76829608afb1d8214bfc Mon Sep 17 00:00:00 2001 From: konnorrogers Date: Mon, 14 Aug 2023 10:45:28 -0400 Subject: [PATCH 3/5] prettier --- src/internal/shoelace-element.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/shoelace-element.test.ts b/src/internal/shoelace-element.test.ts index 3538e517da..fc56bf6c7a 100644 --- a/src/internal/shoelace-element.test.ts +++ b/src/internal/shoelace-element.test.ts @@ -137,7 +137,7 @@ before(async () => { stubCustomElements(); // Check if importing the files automatically registers any components // this path comes through as "button.js" but we really need to test "button.component.js" - path = path.split(".js")[0] + ".component.js" + path = path.split('.js')[0] + '.component.js'; await import('../../dist/' + path); const registeredTags = tagNames.filter(tag => Boolean(window.customElements.get(tag))); From aaaa533b24db19ae93fe145d43fe596d19ca6075 Mon Sep 17 00:00:00 2001 From: konnorrogers Date: Mon, 14 Aug 2023 10:48:05 -0400 Subject: [PATCH 4/5] prettier --- src/internal/shoelace-element.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/internal/shoelace-element.test.ts b/src/internal/shoelace-element.test.ts index fc56bf6c7a..8232b2c5d8 100644 --- a/src/internal/shoelace-element.test.ts +++ b/src/internal/shoelace-element.test.ts @@ -137,7 +137,9 @@ before(async () => { stubCustomElements(); // Check if importing the files automatically registers any components // this path comes through as "button.js" but we really need to test "button.component.js" - path = path.split('.js')[0] + '.component.js'; + if (!path.endsWith('.component.js')) { + path = path.split('.js')[0] + '.component.js'; + } await import('../../dist/' + path); const registeredTags = tagNames.filter(tag => Boolean(window.customElements.get(tag))); From a2e113b526e1015ebefcd8e0b1d35a27117514aa Mon Sep 17 00:00:00 2001 From: konnorrogers Date: Mon, 14 Aug 2023 11:14:12 -0400 Subject: [PATCH 5/5] prettier --- src/internal/shoelace-element.test.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/internal/shoelace-element.test.ts b/src/internal/shoelace-element.test.ts index 8232b2c5d8..d41f333c56 100644 --- a/src/internal/shoelace-element.test.ts +++ b/src/internal/shoelace-element.test.ts @@ -133,16 +133,10 @@ before(async () => { relevantMetadata.forEach(({ tagName, path }) => { it(`Should not register any components: ${tagName}`, async () => { - Sinon.restore(); - stubCustomElements(); - // Check if importing the files automatically registers any components - // this path comes through as "button.js" but we really need to test "button.component.js" - if (!path.endsWith('.component.js')) { - path = path.split('.js')[0] + '.component.js'; - } await import('../../dist/' + path); - const registeredTags = tagNames.filter(tag => Boolean(window.customElements.get(tag))); + // Need to make sure we remove the current tag from the tagNames and *then* see whats been registered. + const registeredTags = tagNames.filter(tag => tag !== tagName && Boolean(window.customElements.get(tag))); const errorMessage = `Expected ${path} to not register any tags, but it registered the following tags: ` +