Skip to content

Commit 914ccf5

Browse files
committed
Write first clunky test
1 parent 34474da commit 914ccf5

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

index.test.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

index.test.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import postcss from "postcss";
2+
import { readFileSync } from "node:fs";
3+
import path from "node:path";
4+
import { describe, it, expect } from "vitest";
5+
6+
const plugin = (await import(".")).default;
7+
8+
async function run(input, output, opts = {}, postcssOpts = {}) {
9+
let result = await postcss([plugin(opts)]).process(input, postcssOpts);
10+
expect(result.css).toEqual(output);
11+
expect(result.warnings()).toHaveLength(0);
12+
}
13+
14+
describe("postcss-assign-layer", () => {
15+
it("does the thing", async () => {
16+
const filePath = path.resolve("test/fixtures/component.module.css");
17+
const file = readFileSync(filePath, "utf-8");
18+
19+
await run(
20+
file,
21+
"@layer components {a {\n color: BurlyWood;\n}\n}\n",
22+
{},
23+
{
24+
from: filePath,
25+
}
26+
);
27+
});
28+
});

test/fixtures/component.module.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
color: BurlyWood;
3+
}

0 commit comments

Comments
 (0)