summaryrefslogtreecommitdiff
path: root/packages/integrations/lit/test/server.test.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2024-08-19 08:12:33 -0400
committerGravatar GitHub <noreply@github.com> 2024-08-19 08:12:33 -0400
commit3822e574aa1d779020983a2d9815b3974a9d911a (patch)
treee73bc12683498256f3a27c3d57033427f0eff71a /packages/integrations/lit/test/server.test.js
parent7ffcae19064a8c912a7d5e8c943952923d20edc5 (diff)
downloadastro-3822e574aa1d779020983a2d9815b3974a9d911a.tar.gz
astro-3822e574aa1d779020983a2d9815b3974a9d911a.tar.zst
astro-3822e574aa1d779020983a2d9815b3974a9d911a.zip
Remove @astrojs/lit (#11680)
* Remove @astrojs/lit This removes the Lit integration as an official integration. The reasons for doing so in 5.0: - Only 1% of Astro users use this integration. - SSR support in Lit is at a lower-level of support due to be a Labs project: https://lit.dev/docs/libraries/labs/, and has been in this state since we added support a couple of years ago. - The maintenance cost of fixing bugs in this integration is too high given the low usage. Some PRs for upgrading Lit versions have taken quite a long time. We can't justify the core team being responsible for this going forward. - There used to be community contributions to fix bugs but this has fallen off for various reasons. Given that, this PR removes the integration as one that is officially supported by the Astro core team. Interested community members are encouraged to fork the integration and continue the development in another repository. * Remove e2e tests and examples * Update lockfile * Remove ssr-lit.test.js * Remove error for no client entrypoint * Remove auto selection of the Lit renderer * Remove lit package.json * Remove lit fixture
Diffstat (limited to 'packages/integrations/lit/test/server.test.js')
-rw-r--r--packages/integrations/lit/test/server.test.js134
1 files changed, 0 insertions, 134 deletions
diff --git a/packages/integrations/lit/test/server.test.js b/packages/integrations/lit/test/server.test.js
deleted file mode 100644
index bcecef2f6..000000000
--- a/packages/integrations/lit/test/server.test.js
+++ /dev/null
@@ -1,134 +0,0 @@
-import * as assert from 'node:assert/strict';
-import { describe, it } from 'node:test';
-import * as cheerio from 'cheerio';
-import { LitElement, html } from 'lit';
-// Must come after lit import because @lit/reactive-element defines
-// globalThis.customElements which the server shim expects to be defined.
-import server from '../server.js';
-
-const { check, renderToStaticMarkup } = server;
-
-describe('check', () => {
- it('should be false with no component', async () => {
- assert.equal(await check(), false);
- });
-
- it('should be false with a registered non-lit component', async () => {
- const tagName = 'non-lit-component';
- // Lit no longer shims HTMLElement globally, so we need to do it ourselves.
- if (!globalThis.HTMLElement) {
- globalThis.HTMLElement = class {};
- }
- customElements.define(tagName, class TestComponent extends HTMLElement {});
- assert.equal(await check(tagName), false);
- });
-
- it('should be true with a registered lit component', async () => {
- const tagName = 'lit-component';
- customElements.define(tagName, class extends LitElement {});
- assert.equal(await check(tagName), true);
- });
-});
-
-describe('renderToStaticMarkup', () => {
- it('should throw error if trying to render an unregistered component', async () => {
- const tagName = 'non-registrered-component';
- try {
- await renderToStaticMarkup(tagName);
- } catch (e) {
- assert.equal(e instanceof TypeError, true);
- }
- });
-
- it('should render empty component with default markup', async () => {
- const tagName = 'nothing-component';
- customElements.define(tagName, class extends LitElement {});
- const render = await renderToStaticMarkup(tagName);
- assert.deepEqual(render, {
- html: `<${tagName}><template shadowroot="open" shadowrootmode="open"><!--lit-part--><!--/lit-part--></template></${tagName}>`,
- });
- });
-
- it('should render component with default markup', async () => {
- const tagName = 'simple-component';
- customElements.define(
- tagName,
- class extends LitElement {
- render() {
- return html`<p>hola</p>`;
- }
- },
- );
- const render = await renderToStaticMarkup(tagName);
- const $ = cheerio.load(render.html);
- assert.equal($(`${tagName} template`).html().includes('<p>hola</p>'), true);
- });
-
- it('should render component with properties and attributes', async () => {
- const tagName = 'props-and-attrs-component';
- const attr1 = 'test';
- const prop1 = 'Daniel';
- customElements.define(
- tagName,
- class extends LitElement {
- static properties = {
- prop1: { type: String },
- };
-
- constructor() {
- super();
- this.prop1 = 'someone';
- }
-
- render() {
- return html`<p>Hello ${this.prop1}</p>`;
- }
- },
- );
- const render = await renderToStaticMarkup(tagName, { prop1, attr1 });
- const $ = cheerio.load(render.html);
- assert.equal($(tagName).attr('attr1'), attr1);
- assert.equal($(`${tagName} template`).text().includes(`Hello ${prop1}`), true);
- });
-
- it('should render nested components', async () => {
- const tagName = 'parent-component';
- const childTagName = 'child-component';
- customElements.define(
- childTagName,
- class extends LitElement {
- render() {
- return html`<p>child</p>`;
- }
- },
- );
- customElements.define(
- tagName,
- class extends LitElement {
- render() {
- return html`<child-component></child-component>`;
- }
- },
- );
- const render = await renderToStaticMarkup(tagName);
- const $ = cheerio.load(render.html);
- assert.equal($(`${tagName} template`).text().includes('child'), true);
- // Child component should have `defer-hydration` attribute so it'll only
- // hydrate after the parent hydrates
- assert.equal($(childTagName).attr('defer-hydration'), '');
- });
-
- it('should render DSD attributes based on shadowRootOptions', async () => {
- const tagName = 'shadow-root-options-component';
- customElements.define(
- tagName,
- class extends LitElement {
- static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
- },
- );
- const render = await renderToStaticMarkup(tagName);
- assert.deepEqual(render, {
- html: `<${tagName}><template shadowroot=\"open\" shadowrootmode=\"open\" shadowrootdelegatesfocus><!--lit-part--><!--/lit-part--></template></${tagName}>`,
- });
- });
-});