|
| 1 | +import assert from 'node:assert/strict'; |
| 2 | +import { before, describe, it } from 'node:test'; |
| 3 | +import * as cheerio from 'cheerio'; |
| 4 | +import { loadFixture } from './test-utils.ts'; |
| 5 | + |
| 6 | +describe('Symlink CSS', () => { |
| 7 | + let realHtml: string; |
| 8 | + let linkedHtml: string; |
| 9 | + |
| 10 | + before( |
| 11 | + async () => { |
| 12 | + // Build from real directory |
| 13 | + const realFixture = await loadFixture({ |
| 14 | + root: './fixtures/symlink-css/', |
| 15 | + }); |
| 16 | + await realFixture.build(); |
| 17 | + realHtml = await realFixture.readFile('/index.html'); |
| 18 | + |
| 19 | + // Build from symlinked directory |
| 20 | + const linkedFixture = await loadFixture({ |
| 21 | + root: './fixtures/symlink-css-linked/', |
| 22 | + }); |
| 23 | + await linkedFixture.build(); |
| 24 | + linkedHtml = await linkedFixture.readFile('/index.html'); |
| 25 | + }, |
| 26 | + { timeout: 60000 }, |
| 27 | + ); |
| 28 | + |
| 29 | + it('should include CSS when building from a symlinked directory', () => { |
| 30 | + const $linked = cheerio.load(linkedHtml); |
| 31 | + const cssLinks = $linked('link[rel=stylesheet]').length; |
| 32 | + const styles = $linked('style').length; |
| 33 | + assert.ok(cssLinks > 0 || styles > 0, 'Should have CSS in symlinked build'); |
| 34 | + }); |
| 35 | + |
| 36 | + it('should have same CSS output as real directory build', () => { |
| 37 | + const $real = cheerio.load(realHtml); |
| 38 | + const $linked = cheerio.load(linkedHtml); |
| 39 | + const realCssCount = $real('link[rel=stylesheet]').length + $real('style').length; |
| 40 | + const linkedCssCount = $linked('link[rel=stylesheet]').length + $linked('style').length; |
| 41 | + assert.equal(linkedCssCount, realCssCount, 'Should have same number of CSS references'); |
| 42 | + }); |
| 43 | +}); |
0 commit comments