Skip to content

Commit

Permalink
fix(overlays): add default tag in OverlayMixin test-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
gerjanvangeest committed Nov 10, 2021
1 parent 3c43184 commit 93b7ad4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-eels-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lion/overlays': patch
---

added default tag in OverlayMixin test-suite
2 changes: 1 addition & 1 deletion .changeset/twelve-zoos-turn.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"providence-analytics": patch
'providence-analytics': patch
---

Correct default target in Windows if no -t
41 changes: 33 additions & 8 deletions packages/overlays/test-suites/OverlayMixin.suite.js
Original file line number Diff line number Diff line change
@@ -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
*/

Expand All @@ -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`
Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit 93b7ad4

Please sign in to comment.