33 lines
959 B
JavaScript
33 lines
959 B
JavaScript
import { expect } from 'chai';
|
|
import { load as cheerioLoad } from 'cheerio';
|
|
import { loadFixture } from './test-utils.js';
|
|
import testAdapter from './test-adapter.js';
|
|
|
|
describe('Lit integration in SSR', () => {
|
|
/** @type {import('./test-utils').Fixture} */
|
|
let fixture;
|
|
|
|
before(async () => {
|
|
fixture = await loadFixture({
|
|
root: './fixtures/lit-element/',
|
|
output: 'server',
|
|
adapter: testAdapter(),
|
|
});
|
|
await fixture.build();
|
|
});
|
|
|
|
async function fetchHTML(path) {
|
|
const app = await fixture.loadTestAdapterApp();
|
|
const request = new Request('http://example.com' + path);
|
|
const response = await app.render(request);
|
|
const html = await response.text();
|
|
return html;
|
|
}
|
|
|
|
it('Is able to load', async () => {
|
|
delete globalThis.window; // On Windows this results in `ReferenceError: window is not defined`
|
|
const html = await fetchHTML('/');
|
|
const $ = cheerioLoad(html);
|
|
expect($('#win').text()).to.equal('function');
|
|
});
|
|
});
|