Skip to content

Commit 7c5c15c

Browse files
committed
fix: Don't swallow any potential errors from postcss processing.
1 parent 5319687 commit 7c5c15c

File tree

1 file changed

+33
-40
lines changed

1 file changed

+33
-40
lines changed

packages/@css-blocks/bem-to-blocks/test/plugin-test.ts

+33-40
Original file line numberDiff line numberDiff line change
@@ -9,76 +9,70 @@ import { bemToBlocksPlugin } from "../src/index";
99
describe("converts BEM to blocks", () => {
1010

1111
it("converts simple classes to blocks", async () => {
12-
postcss([bemToBlocksPlugin])
12+
return postcss([bemToBlocksPlugin])
1313
.process(".jobs-entry__image--inverse-red {color: blue}").then((output) => {
1414
assert.equal(output.toString(), ".image[inverse-red] {color: blue}");
15-
}).catch();
16-
15+
});
1716
});
1817

1918
it("existing attributes remain unchanged", async () => {
20-
postcss([bemToBlocksPlugin])
19+
return postcss([bemToBlocksPlugin])
2120
.process(".jobs-entry__image[state=red] {color: blue}")
2221
.then(output => {
2322
assert.equal(output.toString(), ".image[state=red] {color: blue}");
24-
}).catch();
23+
});
2524
});
2625

2726
it("selector has attributes and a modifier", async () => {
28-
postcss([bemToBlocksPlugin])
27+
return postcss([bemToBlocksPlugin])
2928
.process(".jobs-entry__image--big[state=red] {color: blue}")
3029
.then(output => {
3130
assert.equal(output.toString(), ".image[big][state=red] {color: blue}");
32-
}).catch();
31+
});
3332
});
3433

3534
it("comments are left as is", async () => {
36-
postcss([bemToBlocksPlugin])
35+
return postcss([bemToBlocksPlugin])
3736
.process(`/* adding a comment here */.jobs-entry__image--big[state=red] {color: blue}`)
3837
.then(output => {
3938
assert.equal(output.toString(), `/* adding a comment here */.image[big][state=red] {color: blue}`);
40-
})
41-
.catch();
39+
});
4240
});
4341

4442
it("respects pseudo selectors", async () => {
45-
postcss([bemToBlocksPlugin])
43+
return postcss([bemToBlocksPlugin])
4644
.process(".jobs-entry__image--big::before {color: blue}")
4745
.then(output => {
4846
assert.equal(output.toString(), ".image[big]::before {color: blue}");
49-
})
50-
.catch();
47+
});
5148
});
5249

5350
it("respects sibling selectors", async () => {
54-
postcss([bemToBlocksPlugin])
51+
return postcss([bemToBlocksPlugin])
5552
.process(".jobs-entry__image--big>.jobs-entry__image--small {color: blue}")
5653
.then(output => {
5754
assert.equal(output.toString(), ".image[big]>.image[small] {color: blue}");
58-
})
59-
.catch();
55+
});
6056
});
6157

6258
it("respects scss imports", async () => {
63-
postcss([bemToBlocksPlugin])
59+
return postcss([bemToBlocksPlugin])
6460
.process(`@import "restyle"; .jobs-entry__image--big[state=red] {color: blue}`)
6561
.then(output => {
6662
assert.equal(output.toString(), `@import "restyle"; .image[big][state=red] {color: blue}`);
67-
})
68-
.catch();
63+
});
6964
});
7065

7166
it("respects scss nesting", async () => {
72-
postcss([bemToBlocksPlugin])
67+
return postcss([bemToBlocksPlugin])
7368
.process(`@import "restyle"; .jobs-entry__image--big[state=red] {color: blue}`)
7469
.then(output => {
7570
assert.equal(output.toString(), `@import "restyle"; .image[big][state=red] {color: blue}`);
76-
})
77-
.catch();
71+
});
7872
});
7973

8074
it("other scss syntax", async () => {
81-
postcss([bemToBlocksPlugin])
75+
return postcss([bemToBlocksPlugin])
8276
.process(`
8377
@mixin artdeco-badge(){
8478
@keyframes artdecoBadgeAnimationIn1 {
@@ -103,28 +97,27 @@ describe("converts BEM to blocks", () => {
10397
to { transform: scale(1); }
10498
}
10599
}`.trim());
106-
}).catch();
100+
});
107101
});
108102

109103
it("replaces substates correctly", async () => {
110-
postcss([bemToBlocksPlugin])
111-
.process(`.jobs-entry__image--size-big {color: blue}
112-
.jobs-entry__image--size-small {color: red}`)
113-
.then(output => {
114-
assert.equal(output.toString(), `.image[size="big"] {color: blue}
115-
.image[size="small"] {color: red}`);
116-
})
117-
.catch();
104+
return postcss([bemToBlocksPlugin])
105+
.process(`.jobs-entry__image--size-big {color: blue}
106+
.jobs-entry__image--size-small {color: red}`)
107+
.then(output => {
108+
assert.equal(output.toString(), `.image[size="big"] {color: blue}
109+
.image[size="small"] {color: red}`);
110+
});
118111
});
119112

120113
it("replaces substates correctly when the modifier is on the block", async () => {
121-
postcss([bemToBlocksPlugin])
114+
return postcss([bemToBlocksPlugin])
122115
.process(`.jobs-entry--size-big {color: blue}
123116
.jobs-entry--size-small {color: red}`)
124117
.then(output => {
125118
assert.equal(output.toString(), `:scope[size="big"] {color: blue}
126119
:scope[size="small"] {color: red}`);
127-
}).catch();
120+
});
128121
});
129122

130123
it("calls inquirer for user input", async() => {
@@ -135,12 +128,12 @@ describe("converts BEM to blocks", () => {
135128
stub.onCall(0).returns({block: "my-block"} as any);
136129
stub.onCall(1).returns({element: "my-elem"} as any);
137130
stub.onCall(2).returns({modifier: "my-mod"} as any);
138-
postcss([bemToBlocksPlugin])
139-
.process(`.CLASSINCAPSTHATISNOTBEM {color: blue}`)
140-
.then((output) => {
141-
assert.equal(output.css, ".my-elem[my-mod] {color: blue}");
142-
assert.equal(stub.calledThrice, true);
131+
return postcss([bemToBlocksPlugin])
132+
.process(`.CLASSINCAPSTHATISNOTBEM {color: blue}`)
133+
.then((output) => {
134+
assert.equal(output.css, ".my-elem[my-mod] {color: blue}");
135+
assert.equal(stub.calledThrice, true);
143136

144-
}).catch();
137+
});
145138
});
146139
});

0 commit comments

Comments
 (0)