-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathOpenSwiftUITests.swift
42 lines (35 loc) · 1.24 KB
/
OpenSwiftUITests.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
import XCTest
@testable import OpenSwiftUI
final class OpenSwiftUITests: XCTestCase {
func testExample() {
let body = VStack {
Text("Hello")
Text("World")
}
}
func testAnyViewFromValueWithInDoesNotYieldView() {
let anyView = AnyView(_fromValue: 42)
XCTAssertNil(anyView)
}
func testAnyViewFromValueWithTextYieldsAnyView() {
let expectedText = "Hello"
let value: Any = Text(expectedText)
let anyView = AnyView(_fromValue: value)
XCTAssertNotNil(anyView)
guard let storage = anyView?._storage as? AnyViewStorage<Text> else {
XCTFail("View storage is not an AnyViewStorage of Text")
return
}
switch storage._view._storage {
case .verbatim(let string):
XCTAssertEqual(string, expectedText)
case .anyTextStorage(let storage):
XCTAssertEqual(storage.storage, expectedText)
}
}
static var allTests = [
("testExample", testExample),
("testAnyViewFromValueWithInDoesNotYieldView", testAnyViewFromValueWithInDoesNotYieldView),
("testAnyViewFromValueWithTextYieldsAnyView", testAnyViewFromValueWithTextYieldsAnyView),
]
}