Skip to content

Commit

Permalink
add (skipping+failing) tests for preserving comments (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartveneman authored Dec 13, 2023
1 parent aa83274 commit e64c64e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ function print_list(children, indent_level, css) {
// var(--prop, VALUE)
buffer += print_value(node, 0, css)
} else if (node.type === 'Operator') {
// Put extra spacing around + - / *
// Put extra spacing before + - / *
// but not before a comma
if (node.value !== ',') {
buffer += ' '
Expand Down
21 changes: 21 additions & 0 deletions test/atrules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,25 @@ Atrules('Empty atrule braces are placed on the same line', () => {
assert.is(actual, expected)
})

Atrules.skip('preserves comments', () => {
let actual = format(`
@media /* comment */ all {}
@media all /* comment */ {}
@media (min-width: 1000px /* comment */) {}
@media (/* comment */ min-width: 1000px) {}
@layer /* comment */ {}
`)
let expected = `@media /* comment */ all {}
@media all /* comment */ {}
@media (min-width: 1000px /* comment */) {}
@media (/* comment */ min-width: 1000px) {}
@layer /* comment */ {}
`
assert.is(actual, expected)
})

Atrules.run();
12 changes: 12 additions & 0 deletions test/declarations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,16 @@ Declarations('does not lowercase custom properties', () => {
assert.is(actual, expected)
})

Declarations.skip('preserves comments', () => {
let actual = format(`a {
/* comment */color: green;
color/* comment */: green;
}`)
let expected = `a {
/* comment */color: green;
color/* comment */: green;
}`
assert.is(actual, expected)
})

Declarations.run();
22 changes: 22 additions & 0 deletions test/values.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,26 @@ Values('lowercases dimensions', () => {
assert.is(actual, expected)
})

Values.skip('preserves comments', () => {
let actual = format(`
a {
color: /** comment */red;
color: red/* comment */;
background-image: linear-gradient(/* comment */red, green);
background-image: linear-gradient(red/* comment */, green);
background-image: linear-gradient(red, green/* comment */);
background-image: linear-gradient(red, green)/* comment */
}
`)
let expected = `a {
color: /* comment */red;
color: red/* comment */;
background-image: linear-gradient(/* comment */red, green);
background-image: linear-gradient(red/* comment */, green);
background-image: linear-gradient(red, green/* comment */);
background-image: linear-gradient(red, green)/* comment */
}`
assert.is(actual, expected)
})

Values.run();

0 comments on commit e64c64e

Please sign in to comment.