From 93b7ad48405bb42f19a7deed09b68d1bcab605e4 Mon Sep 17 00:00:00 2001 From: qa46hx Date: Wed, 10 Nov 2021 14:24:09 +0100 Subject: [PATCH] fix(overlays): add default tag in OverlayMixin test-suite --- .changeset/few-eels-leave.md | 5 +++ .changeset/twelve-zoos-turn.md | 2 +- .../test-suites/OverlayMixin.suite.js | 41 +++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 .changeset/few-eels-leave.md diff --git a/.changeset/few-eels-leave.md b/.changeset/few-eels-leave.md new file mode 100644 index 0000000000..96aaeeca9b --- /dev/null +++ b/.changeset/few-eels-leave.md @@ -0,0 +1,5 @@ +--- +'@lion/overlays': patch +--- + +added default tag in OverlayMixin test-suite diff --git a/.changeset/twelve-zoos-turn.md b/.changeset/twelve-zoos-turn.md index c4c08fe64c..e008e46a3a 100644 --- a/.changeset/twelve-zoos-turn.md +++ b/.changeset/twelve-zoos-turn.md @@ -1,5 +1,5 @@ --- -"providence-analytics": patch +'providence-analytics': patch --- Correct default target in Windows if no -t diff --git a/packages/overlays/test-suites/OverlayMixin.suite.js b/packages/overlays/test-suites/OverlayMixin.suite.js index a27e0f9b41..174002c00b 100644 --- a/packages/overlays/test-suites/OverlayMixin.suite.js +++ b/packages/overlays/test-suites/OverlayMixin.suite.js @@ -1,14 +1,22 @@ -import { expect, fixture, html, nextFrame, aTimeout } from '@open-wc/testing'; +import { LitElement } from '@lion/core'; +import { + aTimeout, + defineCE, + expect, + fixture, + html, + nextFrame, + unsafeStatic, +} from '@open-wc/testing'; import sinon from 'sinon'; -import { overlays } from '../src/overlays.js'; import { OverlayController } from '../src/OverlayController.js'; +import { OverlayMixin } from '../src/OverlayMixin.js'; +import { overlays } from '../src/overlays.js'; /** * @typedef {import('../types/OverlayConfig').OverlayConfig} OverlayConfig * @typedef {import('../types/OverlayMixinTypes').DefineOverlayConfig} DefineOverlayConfig * @typedef {import('../types/OverlayMixinTypes').OverlayHost} OverlayHost - * @typedef {import('../types/OverlayMixinTypes').OverlayMixin} OverlayMixin - * @typedef {import('@lion/core').LitElement} LitElement * @typedef {LitElement & OverlayHost & {_overlayCtrl:OverlayController}} OverlayEl */ @@ -19,10 +27,21 @@ function getGlobalOverlayNodes() { } /** - * @param {{tagString:string, tag: object, suffix?:string}} config + * @param {{tagString:string, tag: object, suffix?:string}} [customConfig] */ -export function runOverlayMixinSuite({ tagString, tag, suffix = '' }) { - describe(`OverlayMixin${suffix}`, () => { +export function runOverlayMixinSuite(customConfig) { + const cfg = { + tagString: null, + suffix: '', + ...customConfig, + }; + + describe(`OverlayMixin${cfg.suffix}`, () => { + class TestOverlay extends OverlayMixin(LitElement) {} + + cfg.tagString = cfg.tagString ? cfg.tagString : defineCE(TestOverlay); + const tag = unsafeStatic(cfg.tagString); + it('should not be opened by default', async () => { const el = /** @type {OverlayEl} */ ( await fixture(html` @@ -325,7 +344,13 @@ export function runOverlayMixinSuite({ tagString, tag, suffix = '' }) { }); }); - describe(`OverlayMixin${suffix} nested`, () => { + describe(`OverlayMixin${cfg.suffix} nested`, () => { + class TestOverlayNested extends OverlayMixin(LitElement) {} + + cfg.tagString = cfg.tagString ? cfg.tagString : defineCE(TestOverlayNested); + const { tagString } = cfg; + const tag = unsafeStatic(cfg.tagString); + // For some reason, globalRootNode is not cleared properly on disconnectedCallback from previous overlay test fixtures... // Not sure why this "bug" happens... beforeEach(() => {