How to use the @open-wc/testing-helpers/src/stringFixture.stringFixture 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
it('upgrades elements inserted via importNode to detached element', async () => {
      const name = generateName();

      const iframe = await fixture('');
      const foreignDocument = iframe.contentWindow.document;
      foreignDocument.body.innerHTML = `<div><a is=""></a></div>`;

      // eslint-disable-next-line prefer-destructuring
      const nodeToImport = foreignDocument.body.children[0];

      class Foo extends HTMLAnchorElement {}
      defineCBE(Foo, 'a', name);

      const wrapper = document.importNode(nodeToImport, true);
      expect(wrapper.children[0] instanceof Foo).toBeTruthy();
    });
  });
github corpusculejs / custom-builtin-elements / __tests__ / index.js View on Github external
it('calls the callback when the element is attached to the body', async () =&gt; {
        class Foo extends HTMLAnchorElement {
          connectedCallback() {
            connectedCallbackSpy();
          }
        }

        defineCBE(Foo, 'a');

        const foo = new Foo();

        const wrapper = await fixture('<div></div>');

        const promise = waitForMutationObserverChange(
          document.body,
          observeChildren,
        );

        wrapper.appendChild(foo);

        await promise;

        expect(connectedCallbackSpy).toHaveBeenCalledTimes(1);
      });
    });
github corpusculejs / custom-builtin-elements / __tests__ / index.js View on Github external
it('calls the callback for elements already existing on declaration', async () =&gt; {
        const name = generateName();

        await fixture(
          `<div><a is=""></a></div>` +
            `<div><div><div><a is=""></a></div></div></div>`,
        );

        class Foo extends HTMLAnchorElement {
          connectedCallback() {
            connectedCallbackSpy();
          }
        }

        defineCBE(Foo, 'a', name);

        expect(connectedCallbackSpy).toHaveBeenCalledTimes(2);
      });