Skip to content

Commit e1362b5

Browse files
committed
Add ForEachUITests
1 parent e611cb0 commit e1362b5

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// ForEachUITests.swift
3+
// OpenSwiftUIUITests
4+
5+
import Testing
6+
import SnapshotTesting
7+
8+
@MainActor
9+
@Suite(.snapshots(record: .never, diffTool: diffTool))
10+
struct ForEachUITests {
11+
@Test
12+
func offset() {
13+
struct ContentView: View {
14+
var body: some View {
15+
VStack(spacing: 0) {
16+
ForEach(0 ..< 6) { index in
17+
Color.red.opacity(Double(index) / 6.0 )
18+
}
19+
}
20+
}
21+
}
22+
openSwiftUIAssertSnapshot(of: ContentView())
23+
}
24+
25+
@Test
26+
func keyPath() {
27+
struct ContentView: View {
28+
let opacities = [0, 0.2, 0.4, 0.6, 0.8, 1.0]
29+
30+
var body: some View {
31+
VStack(spacing: 0) {
32+
ForEach(opacities, id: \.self) { opacity in
33+
Color.red.opacity(opacity)
34+
}
35+
}
36+
}
37+
}
38+
openSwiftUIAssertSnapshot(of: ContentView())
39+
}
40+
}

0 commit comments

Comments
 (0)