Skip to content

Commit 61cd492

Browse files
committed
Update to swift-css 0.6.0, add Layout dependency for tests
Breaking change: LazyVGrid now uses Layout.Grid.Lazy.Columns API - Updated tests to use .fractions(), .count(), .autoFit() syntax - Removed duplicate Snapshot typealiases from test files
1 parent 40754f0 commit 61cd492

8 files changed

Lines changed: 56 additions & 32 deletions

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extension Target.Dependency {
2121
static var cssTheming: Self { .product(name: "CSS Theming", package: "swift-css") }
2222
static var translating: Self { .product(name: "Translating", package: "swift-translating") }
2323
static var standards: Self { .product(name: "Standards", package: "swift-standards") }
24+
static var layout: Self { .product(name: "Layout", package: "swift-standards") }
2425
static var colorStandard: Self { .product(name: "Color Standard", package: "swift-color-standard") }
2526
static var cssStandard: Self { .product(name: "CSS Standard", package: "swift-css-standard") }
2627
static var rfc4648: Self { .product(name: "RFC 4648", package: "swift-rfc-4648") }
@@ -49,7 +50,7 @@ let package = Package(
4950
dependencies: [
5051
.package(url: "https://github.com/coenttb/swift-html-rendering", from: "0.1.14"),
5152
.package(url: "https://github.com/coenttb/swift-markdown-html-rendering", from: "0.1.2"),
52-
.package(url: "https://github.com/coenttb/swift-css", from: "0.5.0"),
53+
.package(url: "https://github.com/coenttb/swift-css", from: "0.6.0"),
5354
.package(url: "https://github.com/coenttb/swift-svg", from: "0.3.0"),
5455
.package(url: "https://github.com/coenttb/swift-translating", from: "0.3.0"),
5556
.package(url: "https://github.com/swift-standards/swift-standards", from: "0.20.0"),
@@ -95,6 +96,7 @@ let package = Package(
9596
.html,
9697
.htmlRenderableTestSupport,
9798
.standardsTestSupport,
99+
.layout,
98100
.product(
99101
name: "Translating",
100102
package: "swift-translating",

Tests/HTML Tests/CSS Tests.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ enum CSSNamespace {
1717
#TestSuites
1818
}
1919

20-
extension CSSNamespace.Test {
21-
typealias Snapshot = Test.Snapshot
22-
}
2320

2421
// MARK: - Snapshot Tests - Fluent Chaining
2522

Tests/HTML Tests/DarkModeColor Tests.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ extension DarkModeColor {
1717
#TestSuites
1818
}
1919

20-
extension DarkModeColor.Test {
21-
typealias Snapshot = Test.Snapshot
22-
}
23-
2420
// MARK: - Unit Tests
2521

2622
extension DarkModeColor.Test.Unit {

Tests/HTML Tests/HStack Tests.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ enum HStackTests {
1616
#TestSuites
1717
}
1818

19-
extension HStackTests.Test {
20-
typealias Snapshot = Test.Snapshot
21-
}
2219

2320
// MARK: - Snapshot Tests
2421

Tests/HTML Tests/HTML.Document Tests.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ enum HTMLDocumentTests {
1818
#TestSuites
1919
}
2020

21-
extension HTMLDocumentTests.Test {
22-
typealias Snapshot = Test.Snapshot
23-
}
2421

2522
// MARK: - Unit Tests
2623

@@ -78,7 +75,7 @@ extension HTMLDocumentTests.Test.Unit {
7875

7976
@Test("Grid Layout")
8077
func gridLayout() throws {
81-
let grid = LazyVGrid(columns: [1, 2, 1]) {
78+
let grid = LazyVGrid(columns: .fractions([1, 2, 1])) {
8279
div { "Item 1" }
8380
div { "Item 2" }
8481
div { "Item 3" }

Tests/HTML Tests/LazyVGrid Tests.swift

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import HTML
99
import HTML_Rendering_TestSupport
10+
import Layout
1011
import OrderedCollections
1112
import StandardsTestSupport
1213
import Testing
@@ -17,17 +18,14 @@ enum LazyVGridTests {
1718
#TestSuites
1819
}
1920

20-
extension LazyVGridTests.Test {
21-
typealias Snapshot = Test.Snapshot
22-
}
2321

2422
// MARK: - Snapshot Tests
2523

2624
extension LazyVGridTests.Test.Snapshot {
27-
@Test("LazyVGrid with simple columns")
25+
@Test("LazyVGrid with fractions columns")
2826
func lazyVGrid() {
2927
assertInlineSnapshot(
30-
of: LazyVGrid(columns: [1, 2]) {
28+
of: LazyVGrid(columns: .fractions([1, 2])) {
3129
div { "Item 1" }
3230
div { "Item 2" }
3331
div { "Item 3" }
@@ -50,14 +48,12 @@ extension LazyVGridTests.Test.Snapshot {
5048

5149
@Test("LazyVGrid with media queries")
5250
func lazyVGridWithMediaQueries() {
53-
let columns: OrderedDictionary<CSS_Standard.Media?, [Int]> = [
54-
nil: [1],
55-
.desktop: [1, 1],
56-
]
57-
5851
assertInlineSnapshot(
5952
of: LazyVGrid(
60-
columns: columns,
53+
columns: [
54+
nil: .count(1),
55+
.desktop: .fractions([1, 1]),
56+
],
6157
horizontalSpacing: .px(10),
6258
verticalSpacing: .px(20)
6359
) {
@@ -77,4 +73,49 @@ extension LazyVGridTests.Test.Snapshot {
7773
"""
7874
}
7975
}
76+
77+
@Test("LazyVGrid with count columns")
78+
func lazyVGridWithCount() {
79+
assertInlineSnapshot(
80+
of: LazyVGrid(columns: .count(3)) {
81+
div { "Item 1" }
82+
div { "Item 2" }
83+
div { "Item 3" }
84+
},
85+
as: .html
86+
) {
87+
"""
88+
89+
<div class="grid-template-columns-0 display-1 width-2">
90+
<div>Item 1
91+
</div>
92+
<div>Item 2
93+
</div>
94+
<div>Item 3
95+
</div>
96+
</div>
97+
"""
98+
}
99+
}
100+
101+
@Test("LazyVGrid with autoFit columns")
102+
func lazyVGridWithAutoFit() {
103+
assertInlineSnapshot(
104+
of: LazyVGrid(columns: .autoFit(minWidth: 200)) {
105+
div { "Item 1" }
106+
div { "Item 2" }
107+
},
108+
as: .html
109+
) {
110+
"""
111+
112+
<div class="grid-template-columns-0 display-1 width-2">
113+
<div>Item 1
114+
</div>
115+
<div>Item 2
116+
</div>
117+
</div>
118+
"""
119+
}
120+
}
80121
}

Tests/HTML Tests/Spacer Tests.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ extension Spacer {
1616
#TestSuites
1717
}
1818

19-
extension Spacer.Test {
20-
typealias Snapshot = Test.Snapshot
21-
}
2219

2320
// MARK: - Snapshot Tests
2421

Tests/HTML Tests/VStack Tests.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ enum VStackTests {
1616
#TestSuites
1717
}
1818

19-
extension VStackTests.Test {
20-
typealias Snapshot = Test.Snapshot
21-
}
2219

2320
// MARK: - Snapshot Tests
2421

0 commit comments

Comments
 (0)