Files
postcss/test/stringify.test.ts
T
Haïm DimerandGitHub 05a93532d1 Preserve the BOM when stringifying (#2119)
PostCSS aims for byte-to-byte equal output, but the stringifier dropped a
leading byte order mark: `parse('a{}').toString()` returned `a{}`. The
BOM is already detected (`Input#hasBOM`) but was never re-emitted, so the
`bom.css` round-trip test had to be skipped.

Emit the BOM in `Stringifier#root` when the source had one, and re-enable the
previously skipped test.
2026-07-28 11:38:17 +02:00

19 lines
364 B
TypeScript
Executable File

import { eachTest } from 'postcss-parser-tests'
import { test } from 'uvu'
import { is } from 'uvu/assert'
import { parse, stringify } from '../lib/postcss.js'
eachTest((name, css) => {
test(`stringifies ${name}`, () => {
let root = parse(css)
let result = ''
stringify(root, i => {
result += i
})
is(result, css)
})
})
test.run()