2022-03-28 20:48:06 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import { load as cheerioLoad } from 'cheerio';
|
|
|
|
import { loadFixture } from './test-utils.js';
|
|
|
|
|
|
|
|
// Asset bundling
|
|
|
|
describe('Page-level styles', () => {
|
|
|
|
let fixture;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({
|
2022-04-02 18:29:59 +00:00
|
|
|
root: './fixtures/page-level-styles/',
|
2023-08-18 15:46:47 +00:00
|
|
|
// test suite was authored when inlineStylesheets defaulted to never
|
|
|
|
build: { inlineStylesheets: 'never' },
|
2022-03-28 20:48:06 +00:00
|
|
|
});
|
|
|
|
await fixture.build();
|
|
|
|
});
|
|
|
|
|
2022-03-28 20:49:06 +00:00
|
|
|
it("Doesn't add page styles for a page without style imports", async () => {
|
2022-03-28 20:48:06 +00:00
|
|
|
let html = await fixture.readFile('/index.html');
|
|
|
|
let $ = await cheerioLoad(html);
|
|
|
|
expect($('link').length).to.equal(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Does add page styles for pages with style imports (or deps)', async () => {
|
|
|
|
let html = await fixture.readFile('/blog/index.html');
|
|
|
|
let $ = await cheerioLoad(html);
|
|
|
|
expect($('link').length).to.equal(1);
|
|
|
|
});
|
|
|
|
});
|