Skip to content

Commit ba4f4b4

Browse files
committed
Add more sensitive plugins tests
1 parent 12efd77 commit ba4f4b4

File tree

7 files changed

+36
-24
lines changed

7 files changed

+36
-24
lines changed

test/fixtures/plugins-imported.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import 'plugins-root';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
foo-converted {}
2+
bar-converted {}
3+
baz-converted {}

test/fixtures/plugins-root.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
foo {}
2+
bar {}
3+
baz {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
foo-converted {}
2+
bar-converted {}
3+
baz-converted {}

test/fixtures/plugins.css

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

test/fixtures/plugins.expected.css

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

test/plugins.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,37 @@ import scss from "postcss-scss"
44
import atImport from ".."
55
import compareFixtures from "./lib/compare-fixtures"
66

7-
test("should apply plugins", t => {
8-
return compareFixtures(t, "plugins", {
7+
test("should apply plugins to root", t => {
8+
return compareFixtures(t, "plugins-root", {
99
plugins: [
10-
postcss.plugin("postcss-no-foo", () => {
11-
return css => {
12-
css.walkDecls("foo", decl => {
13-
decl.remove()
14-
})
15-
}
16-
}),
17-
postcss.plugin("postcss-no-bar", () => {
18-
return css => {
19-
css.walkDecls("bar", decl => {
20-
decl.remove()
21-
})
22-
}
23-
}),
10+
css => {
11+
css.walkRules(rule => {
12+
rule.selector += "-converted"
13+
})
14+
},
2415
],
2516
})
2617
})
2718

19+
test("should apply plugins to imported files", t => {
20+
return compareFixtures(t, "plugins-imported", {
21+
plugins: [
22+
css => {
23+
css.walkRules(rule => {
24+
if (rule.selector === "foo") {
25+
rule.remove()
26+
}
27+
else {
28+
rule.selector += "-converted"
29+
}
30+
})
31+
},
32+
],
33+
}, {
34+
from: "fixtures/plugins-imported.css",
35+
})
36+
})
37+
2838
test("should error when value is not an array", t => {
2939
return postcss()
3040
.use(atImport({

0 commit comments

Comments
 (0)