Skip to content

Commit 4e89e5e

Browse files
committed
Use Prettier to normalize tests
1 parent 572b293 commit 4e89e5e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

index.test.mjs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
import postcss from "postcss";
21
import { readFileSync } from "node:fs";
32
import path from "node:path";
3+
import postcss from "postcss";
4+
import prettier from "prettier";
45
import { describe, it, expect } from "vitest";
56

67
const plugin = (await import(".")).default;
78

8-
async function run(input, output, opts = {}, postcssOpts = {}) {
9+
// We don't care about formatting differences, so normalize with prettier
10+
function format(css) {
11+
return prettier.format(css, { parser: "css" });
12+
}
13+
14+
async function run(input, output, opts, postcssOpts = {}) {
915
let result = await postcss([plugin(opts)]).process(input, postcssOpts);
10-
expect(result.css).toEqual(output);
16+
expect(format(result.css)).toEqual(format(output));
1117
expect(result.warnings()).toHaveLength(0);
1218
}
1319

1420
describe("postcss-assign-layer", () => {
15-
it("does the thing", async () => {
21+
it("adds component layer to module.css files by default", async () => {
1622
const filePath = path.resolve("test/fixtures/component.module.css");
1723
const file = readFileSync(filePath, "utf-8");
1824

1925
await run(
2026
file,
21-
"@layer components {a {\n color: BurlyWood;\n}\n}\n",
22-
{},
27+
"@layer components { a { color: BurlyWood; } }",
28+
undefined,
2329
{
2430
from: filePath,
2531
}

0 commit comments

Comments
 (0)