How to use the @open-wc/testing-helpers/src/helpers.defineCE function in @open-wc/testing-helpers

To help you get started, we’ve selected a few @open-wc/testing-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github corpusculejs / custom-builtin-elements / __tests__ / index.js View on Github external
class Bar extends HTMLAnchorElement {
        disconnectedCallback() {
          disconnectedCallbackSpy();
        }
      }
      const name = defineCBE(Bar, 'a');

      class Foo extends HTMLElement {
        constructor() {
          super();
          const root = this.attachShadow({mode: 'open'});
          root.innerHTML = `<a is=""></a>`;
        }
      }

      const tag = defineCE(Foo);
      const foo = await fixture(`&lt;${tag}&gt;`);

      // eslint-disable-next-line prefer-destructuring
      const bar = foo.shadowRoot.children[0];

      const promise = waitForMutationObserverChange(
        foo.shadowRoot,
        observeChildren,
      );
      bar.parentNode.removeChild(bar);

      await promise;

      expect(disconnectedCallbackSpy).toHaveBeenCalledTimes(1);
    });
github corpusculejs / custom-builtin-elements / __tests__ / index.js View on Github external
}
      }

      const name = defineCBE(Bar, 'a');

      class Foo extends HTMLElement {
        constructor() {
          super();
          const root = this.attachShadow({mode: 'open'});
          root.innerHTML =
            `<a is=""></a><div>` +
            `<div><a is=""></a></div></div>`;
        }
      }

      defineCE(Foo);
      const foo = new Foo();

      expect(foo.shadowRoot.children[0] instanceof Bar).toBeTruthy();
      expect(connectedCallbackSpy).not.toHaveBeenCalled();
    });
github corpusculejs / custom-builtin-elements / __tests__ / registry.js View on Github external
        expect(() => defineCE(Foo)).toThrowError(
          'Not supported in this environment',