* wip: config migration * fix: formatting * refactor: projectRoot -> root * refactor: pageUrlFormat -> format * refactor: buildOptions.site -> site * refactor: public -> publicDir * refactor: dist -> outDir * refactor: styleOptions -> style * fix: some dist tests -> outDir * refactor: remove legacyBuild (with TODOs) * refactor: more legacyBuild cleanup * refactor: server host and port * fix: remove experimentalStaticBuild CLI flag * refactor: src -> srcDir * refactor: devOptions.trailing -> trailing * refactor: remove sitemap + related flags * refactor: experimentalSSR -> experimental.ssr * fix: last devOptions * refactor: drafts -> markdown.drafts * fix: TS error on port as const * refactor: remove pages * refactor: more --project-root updates * refactor: markdownOptions -> markdown * fix: remaining type errors * feat: update AstroUserConfig * refactor: update CLI flag mapper + server mapper * fix: loadFixture projectRoot * fix: merge CLI flags before validating / transforming * wip: attempt to fix bad createRouteManifest config * refactor: combine config.base and config.site * fix: skip route manifest test for now * fix: site and base handling * refactor: update failing config testes * fix: build failure * feat: update config types with migration help * chore: update types * fix(deno): update deno fixture * chore: remove config migration logic * chore: remove logLevel * chore: clean-up config types * chore: update config warning * chore: add changeset * Sitemap Integration (#2965) * feat: add sitemap filter config option * feat: add canonicalURL sitemap config option * docs: update sitemap README * fix: update for new config * fix: filter not being applied * chore: changeset Co-authored-by: bholmesdev <hey@bholmes.dev> * fred pass * fix: Astro.resolve typo * fix: public => publicDir Co-authored-by: bholmesdev <hey@bholmes.dev> Co-authored-by: Fred K. Schott <fkschott@gmail.com>
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
import { expect } from 'chai';
|
|
import cheerio from 'cheerio';
|
|
import { loadFixture } from './test-utils.js';
|
|
|
|
describe('CSS Bundling (ESM import)', () => {
|
|
let fixture;
|
|
|
|
before(async () => {
|
|
fixture = await loadFixture({
|
|
root: './fixtures/astro-css-bundling-import/',
|
|
});
|
|
await fixture.build();
|
|
});
|
|
|
|
it('CSS output in import order', async () => {
|
|
// note: this test is a little confusing, but the main idea is that
|
|
// page-2.astro contains all of page-1.astro, plus some unique styles.
|
|
// we only test page-2 to ensure the proper order is observed.
|
|
const html = await fixture.readFile('/page-2/index.html');
|
|
const $ = cheerio.load(html);
|
|
|
|
let css = '';
|
|
|
|
for (const style of $('link[rel=stylesheet]')) {
|
|
const href = style.attribs.href.replace(/^\.\./, '');
|
|
if (!href) continue;
|
|
css += await fixture.readFile(href);
|
|
}
|
|
|
|
// test 1: insure green comes after red (site.css)
|
|
expect(css.indexOf('p{color:green}')).to.be.greaterThan(css.indexOf('p{color:red}'));
|
|
|
|
// test 2: insure green comes after blue (page-1.css)
|
|
expect(css.indexOf('p{color:green}')).to.be.greaterThan(css.indexOf('p{color:#00f}'));
|
|
});
|
|
|
|
it('no empty CSS files', async () => {
|
|
for (const page of ['/page-1/index.html', '/page-2/index.html']) {
|
|
const html = await fixture.readFile(page);
|
|
const $ = cheerio.load(html);
|
|
|
|
for (const style of $('link[rel=stylesheet]')) {
|
|
const href = style.attribs.href.replace(/^\.\./, '');
|
|
if (!href) continue;
|
|
const css = await fixture.readFile(href);
|
|
|
|
expect(css).to.be.ok;
|
|
}
|
|
}
|
|
});
|
|
});
|