Skip to content

Commit a4243be

Browse files
authored
chore: add test for minifying nth selectors (#190)
1 parent 11dc1b0 commit a4243be

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

test/selectors.test.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,30 @@ d::first-letter {}`
117117
expect(actual).toEqual(expected)
118118
})
119119

120-
test('formats selectors with Nth', () => {
121-
let fixtures = [
122-
[`li:nth-child(3n-2) {}`, `li:nth-child(3n -2) {}`],
123-
[`li:nth-child(0n+1) {}`, `li:nth-child(0n + 1) {}`],
124-
[`li:nth-child(even of .noted) {}`, `li:nth-child(even of .noted) {}`],
125-
[`li:nth-child(2n of .noted) {}`, `li:nth-child(2n of .noted) {}`],
126-
[`li:nth-child(-n + 3 of .noted) {}`, `li:nth-child(-n + 3 of .noted) {}`],
127-
[`li:nth-child(-n+3 of li.important) {}`, `li:nth-child(-n + 3 of li.important) {}`],
128-
[`p:nth-child(n+8):nth-child(-n+15) {}`, `p:nth-child(n + 8):nth-child(-n + 15) {}`],
129-
]
120+
test.each([
121+
[`li:nth-child(3n-2) {}`, `li:nth-child(3n -2) {}`],
122+
[`li:nth-child(0n+1) {}`, `li:nth-child(0n + 1) {}`],
123+
[`li:nth-child(even of .noted) {}`, `li:nth-child(even of .noted) {}`],
124+
[`li:nth-child(2n of .noted) {}`, `li:nth-child(2n of .noted) {}`],
125+
[`li:nth-child(-n + 3 of .noted) {}`, `li:nth-child(-n + 3 of .noted) {}`],
126+
[`li:nth-child(-n+3 of li.important) {}`, `li:nth-child(-n + 3 of li.important) {}`],
127+
[`p:nth-child(n+8):nth-child(-n+15) {}`, `p:nth-child(n + 8):nth-child(-n + 15) {}`],
128+
])('formats nth selector: %s', (css, expected) => {
129+
let actual = format(css)
130+
expect(actual).toEqual(expected)
131+
})
130132

131-
for (let [css, expected] of fixtures) {
132-
let actual = format(css)
133-
expect(actual).toEqual(expected)
134-
}
133+
test.each([
134+
[`li:nth-child(3n-2) {}`, `li:nth-child(3n-2){}`],
135+
[`li:nth-child(0n+1) {}`, `li:nth-child(0n+1){}`],
136+
[`li:nth-child(even of .noted) {}`, `li:nth-child(even of .noted){}`],
137+
[`li:nth-child(2n of .noted) {}`, `li:nth-child(2n of .noted){}`],
138+
[`li:nth-child(-n + 3 of .noted) {}`, `li:nth-child(-n+3 of .noted){}`],
139+
[`li:nth-child(-n+3 of li.important) {}`, `li:nth-child(-n+3 of li.important){}`],
140+
[`p:nth-child(n+8):nth-child(-n+15) {}`, `p:nth-child(n+8):nth-child(-n+15){}`],
141+
])('minifies nth selector: %s', (css, expected) => {
142+
let actual = format(css, { minify: true })
143+
expect(actual).toEqual(expected)
135144
})
136145

137146
test('formats multiline selectors', () => {

0 commit comments

Comments
 (0)