Skip to content

Commit 65916b0

Browse files
committed
test(in-deep-nested-selector): add test case
1 parent f4f9c80 commit 65916b0

4 files changed

Lines changed: 39 additions & 0 deletions

File tree

.changeset/calm-mirrors-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'postcss-color-scheme': patch
3+
---
4+
5+
added test case where used in deeply nested selectors

lib/color-scheme.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,14 @@ test('used at root', async () => {
137137
processor.process(input, { from: undefined })
138138
).rejects.toThrowError(/Expect @dark to be nested in a selector./);
139139
});
140+
141+
test.only('in deep nested selector', async () => {
142+
const input = readCSS('./tests/in-deep-nested-selector.input.css');
143+
const output = readCSS('./tests/in-deep-nested-selector.output.css');
144+
145+
/** @type {any} */
146+
const processor = postcss([plugin(), postcssNesting]);
147+
const result = await processor.process(input, { from: undefined });
148+
149+
compareCSS(output, result.css);
150+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@media (max-width: 767px) {
2+
.grandparent {
3+
& .parent {
4+
& .child {
5+
@dark {
6+
color: red;
7+
}
8+
}
9+
}
10+
}
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@media (max-width: 767px) {
2+
html[data-color-scheme="dark"] .grandparent .parent .child {
3+
color: red;
4+
}
5+
6+
@media (prefers-color-scheme: dark) {
7+
html:not([data-color-scheme="light"]) .grandparent .parent .child {
8+
color: red;
9+
}
10+
}
11+
}
12+

0 commit comments

Comments
 (0)