diff options
author | 2024-02-02 13:17:32 +0200 | |
---|---|---|
committer | 2024-02-02 11:17:32 +0000 | |
commit | f4c2ba870eb8c74aa2f235d008dd0a30d70a4723 (patch) | |
tree | 681194a4ac4d68695c29c7c05a9dd0596b19f12a /packages/integrations/lit/test/server.test.js | |
parent | 587b373009e7399ab8ac94e17bb40eb5f5ac8082 (diff) | |
download | astro-f4c2ba870eb8c74aa2f235d008dd0a30d70a4723.tar.gz astro-f4c2ba870eb8c74aa2f235d008dd0a30d70a4723.tar.zst astro-f4c2ba870eb8c74aa2f235d008dd0a30d70a4723.zip |
chore(@astrojs/integrations/lit): use Node.js for testing (#9944)
Diffstat (limited to 'packages/integrations/lit/test/server.test.js')
-rw-r--r-- | packages/integrations/lit/test/server.test.js | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/packages/integrations/lit/test/server.test.js b/packages/integrations/lit/test/server.test.js index 08c69965a..4b58715af 100644 --- a/packages/integrations/lit/test/server.test.js +++ b/packages/integrations/lit/test/server.test.js @@ -1,5 +1,6 @@ -import { expect } from 'chai'; import { LitElement, html } from 'lit'; +import { describe, it } from 'node:test'; +import * as assert from 'node:assert/strict'; // 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'; @@ -9,7 +10,7 @@ const { check, renderToStaticMarkup } = server; describe('check', () => { it('should be false with no component', async () => { - expect(await check()).to.equal(false); + assert.equal(await check(), false); }); it('should be false with a registered non-lit component', async () => { @@ -19,13 +20,13 @@ describe('check', () => { globalThis.HTMLElement = class {}; } customElements.define(tagName, class TestComponent extends HTMLElement {}); - expect(await check(tagName)).to.equal(false); + 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 {}); - expect(await check(tagName)).to.equal(true); + assert.equal(await check(tagName), true); }); }); @@ -35,7 +36,7 @@ describe('renderToStaticMarkup', () => { try { await renderToStaticMarkup(tagName); } catch (e) { - expect(e).to.be.an.instanceOf(TypeError); + assert.equal(e instanceof TypeError, true); } }); @@ -43,7 +44,7 @@ describe('renderToStaticMarkup', () => { const tagName = 'nothing-component'; customElements.define(tagName, class extends LitElement {}); const render = await renderToStaticMarkup(tagName); - expect(render).to.deep.equal({ + assert.deepEqual(render, { html: `<${tagName}><template shadowroot="open" shadowrootmode="open"><!--lit-part--><!--/lit-part--></template></${tagName}>`, }); }); @@ -60,7 +61,7 @@ describe('renderToStaticMarkup', () => { ); const render = await renderToStaticMarkup(tagName); const $ = cheerio.load(render.html); - expect($(`${tagName} template`).html()).to.contain('<p>hola</p>'); + assert.equal($(`${tagName} template`).html().includes('<p>hola</p>'), true); }); it('should render component with properties and attributes', async () => { @@ -86,8 +87,8 @@ describe('renderToStaticMarkup', () => { ); const render = await renderToStaticMarkup(tagName, { prop1, attr1 }); const $ = cheerio.load(render.html); - expect($(tagName).attr('attr1')).to.equal(attr1); - expect($(`${tagName} template`).text()).to.contain(`Hello ${prop1}`); + assert.equal($(tagName).attr('attr1'), attr1); + assert.equal($(`${tagName} template`).text().includes(`Hello ${prop1}`), true); }); it('should render nested components', async () => { @@ -111,10 +112,10 @@ describe('renderToStaticMarkup', () => { ); const render = await renderToStaticMarkup(tagName); const $ = cheerio.load(render.html); - expect($(`${tagName} template`).text()).to.contain('child'); + assert.equal($(`${tagName} template`).text().includes('child'), true); // Child component should have `defer-hydration` attribute so it'll only // hydrate after the parent hydrates - expect($(childTagName).attr('defer-hydration')).to.equal(''); + assert.equal($(childTagName).attr('defer-hydration'), ''); }); it('should render DSD attributes based on shadowRootOptions', async () => { @@ -126,7 +127,7 @@ describe('renderToStaticMarkup', () => { } ); const render = await renderToStaticMarkup(tagName); - expect(render).to.deep.equal({ + assert.deepEqual(render, { html: `<${tagName}><template shadowroot=\"open\" shadowrootmode=\"open\" shadowrootdelegatesfocus><!--lit-part--><!--/lit-part--></template></${tagName}>`, }); }); |