astro/packages/astro/test/astro-css-bundling-nested-layouts.test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.1 KiB
JavaScript
Raw Normal View History

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