Skip to content

Commit a844dbd

Browse files
committed
Readme update & new tests
1 parent 1616699 commit a844dbd

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let css = Stylesheet {
3636
}
3737
}
3838

39-
print(StylesheetRenderer().render(css))
39+
print(StylesheetRenderer(minify: false, indent: 4).render(css))
4040
```
4141

4242
## Credits & references

Tests/SwiftCssTests/SwiftCssTests.swift

+33-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,39 @@ import XCTest
1010

1111
final class SwiftCssTests: XCTestCase {
1212

13+
func testMinifiedStylesheet() {
14+
let css = Stylesheet {
15+
Charset("UTF-8")
16+
Media {
17+
Root {
18+
Margin(horizontal: .px(8.5), vertical: .px(8))
19+
Padding(horizontal: .px(8), vertical: .px(8))
20+
}
21+
}
22+
}
23+
XCTAssertEqual(StylesheetRenderer(minify: true, indent: 2).render(css), #"@charset "UTF-8";:root{margin:8.5px 8px;padding:8px 8px}"#)
24+
}
25+
26+
func testCustomIndentStylesheet() {
27+
let css = Stylesheet {
28+
Charset("UTF-8")
29+
Media {
30+
Root {
31+
Margin(horizontal: .px(8.5), vertical: .px(8))
32+
Padding(horizontal: .px(8), vertical: .px(8))
33+
}
34+
}
35+
}
36+
print(StylesheetRenderer(indent: 2).render(css))
37+
XCTAssertEqual(StylesheetRenderer(indent: 2).render(css), #"""
38+
@charset "UTF-8";
39+
:root {
40+
margin: 8.5px 8px;
41+
padding: 8px 8px;
42+
}
43+
"""#)
44+
}
45+
1346
func testStylesheet() {
1447
let css = Stylesheet {
1548
Charset("UTF-8")
@@ -62,8 +95,6 @@ final class SwiftCssTests: XCTestCase {
6295
"""#)
6396
}
6497

65-
66-
6798
func testVariable() {
6899
let css = Stylesheet {
69100
Media {

0 commit comments

Comments
 (0)