7250e4e86d
* feat: add html package * feat: support assets in HTML * feat(html): upgrade html integration * feat(html): add `@astrojs/html` integration * feat(html): add html support to astro core * test(html): update html tests with package.json files * chore: add changeset * fix: remove import cycle * chore: fix types * refactor: remove @astrojs/html, add to core * chore: update types for `*.html` * fix: move *.html to astro/env Co-authored-by: Nate Moore <nate@astro.build>
75 lines
1.6 KiB
JavaScript
75 lines
1.6 KiB
JavaScript
import { expect } from 'chai';
|
|
import * as cheerio from 'cheerio';
|
|
import { loadFixture } from './test-utils.js';
|
|
|
|
describe('HTML Slots', () => {
|
|
let fixture;
|
|
|
|
before(async () => {
|
|
fixture = await loadFixture({
|
|
root: './fixtures/html-slots/',
|
|
});
|
|
});
|
|
|
|
describe('build', () => {
|
|
before(async () => {
|
|
await fixture.build();
|
|
});
|
|
|
|
it('works', async () => {
|
|
const html = await fixture.readFile('/index.html');
|
|
const $ = cheerio.load(html);
|
|
|
|
const slotDefault = $('#default');
|
|
expect(slotDefault.text()).to.equal('Default');
|
|
|
|
const a = $('#a');
|
|
expect(a.text().trim()).to.equal('A');
|
|
|
|
const b = $('#b');
|
|
expect(b.text().trim()).to.equal('B');
|
|
|
|
const c = $('#c');
|
|
expect(c.text().trim()).to.equal('C');
|
|
|
|
const inline = $('#inline');
|
|
expect(inline.html()).to.equal('<slot is:inline=""></slot>');
|
|
});
|
|
});
|
|
|
|
describe('dev', () => {
|
|
let devServer;
|
|
|
|
before(async () => {
|
|
devServer = await fixture.startDevServer();
|
|
});
|
|
|
|
after(async () => {
|
|
await devServer.stop();
|
|
});
|
|
|
|
it('works', async () => {
|
|
const res = await fixture.fetch('/');
|
|
|
|
expect(res.status).to.equal(200);
|
|
|
|
const html = await res.text();
|
|
const $ = cheerio.load(html);
|
|
|
|
const slotDefault = $('#default');
|
|
expect(slotDefault.text()).to.equal('Default');
|
|
|
|
const a = $('#a');
|
|
expect(a.text().trim()).to.equal('A');
|
|
|
|
const b = $('#b');
|
|
expect(b.text().trim()).to.equal('B');
|
|
|
|
const c = $('#c');
|
|
expect(c.text().trim()).to.equal('C');
|
|
|
|
const inline = $('#inline');
|
|
expect(inline.html()).to.equal('<slot is:inline=""></slot>');
|
|
});
|
|
});
|
|
});
|