-
Notifications
You must be signed in to change notification settings - Fork 44
/
ViewBuildTests.swift
51 lines (42 loc) · 1.2 KB
/
ViewBuildTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import XCTest
@testable import SwiftTUI
final class ViewBuildTests: XCTestCase {
func test_VStack_TupleView2() throws {
struct MyView: View {
var body: some View {
VStack {
Text("One")
Text("Two")
}
}
}
let control = try buildView(MyView())
XCTAssertEqual(control.treeDescription, """
→ VStackControl
→ TextControl
→ TextControl
""")
}
func test_conditional_VStack() throws {
struct MyView: View {
@State var value = true
var body: some View {
if value {
VStack {
Text("One")
}
}
}
}
let control = try buildView(MyView())
XCTAssertEqual(control.treeDescription, """
→ VStackControl
→ TextControl
""")
}
private func buildView<V: View>(_ view: V) throws -> Control {
let node = Node(view: VStack(content: view).view)
node.build()
return try XCTUnwrap(node.control?.children.first)
}
}