2021-12-07 22:01:45 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import cheerio from 'cheerio';
|
|
|
|
import { loadFixture } from './test-utils.js';
|
|
|
|
|
|
|
|
describe('nested layouts', () => {
|
2021-12-22 21:11:05 +00:00
|
|
|
let fixture;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({ projectRoot: './fixtures/astro-css-bundling-nested-layouts/' });
|
|
|
|
await fixture.build();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('page-1 has all CSS', async () => {
|
|
|
|
const html = await fixture.readFile('/page-1/index.html');
|
|
|
|
const $ = cheerio.load(html);
|
|
|
|
|
|
|
|
const stylesheets = $('link[rel=stylesheet]')
|
|
|
|
.toArray()
|
|
|
|
.map((el) => el.attribs.href);
|
|
|
|
|
|
|
|
// page-one.[hash].css exists
|
|
|
|
expect(stylesheets.some((href) => /page-one\.\w+\.css/.test(href))).to.be.true;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('page-2 has all CSS', async () => {
|
|
|
|
const html = await fixture.readFile('/page-2/index.html');
|
|
|
|
const $ = cheerio.load(html);
|
|
|
|
|
|
|
|
const stylesheets = $('link[rel=stylesheet]')
|
|
|
|
.toArray()
|
|
|
|
.map((el) => el.attribs.href);
|
|
|
|
|
|
|
|
// page-one.[hash].css exists
|
|
|
|
expect(stylesheets.some((href) => /page-one\.\w+\.css/.test(href))).to.be.true;
|
|
|
|
// page-2.[hash].css exists
|
|
|
|
expect(stylesheets.some((href) => /page-2\.\w+\.css/.test(href))).to.be.true;
|
|
|
|
});
|
2021-12-07 22:01:45 +00:00
|
|
|
});
|