@@ -28,36 +28,36 @@ enum TestUtils {
28
28
}
29
29
#endif
30
30
31
- func XCTAssertViewIntrospection< V : View , PV : AnyObject > (
32
- of type: PV . Type ,
33
- @ViewBuilder view: ( Spies < PV > ) -> V ,
34
- extraAssertions: ( [ PV ] ) -> Void = { _ in } ,
31
+ func XCTAssertViewIntrospection< Entity : AnyObject > (
32
+ of type: Entity . Type ,
33
+ @ViewBuilder view: ( Spies < Entity > ) -> some View ,
34
+ extraAssertions: ( [ Entity ] ) -> Void = { _ in } ,
35
35
file: StaticString = #file,
36
36
line: UInt = #line
37
37
) {
38
- let spies = Spies < PV > ( )
38
+ let spies = Spies < Entity > ( )
39
39
let view = view ( spies)
40
40
TestUtils . present ( view: view)
41
41
XCTWaiter ( delegate: spies) . wait ( for: spies. expectations. values. map ( \. 0 ) , timeout: 3 )
42
- extraAssertions ( spies. objects . sorted ( by: { $0. key < $1. key } ) . map ( \. value) )
42
+ extraAssertions ( spies. entities . sorted ( by: { $0. key < $1. key } ) . map ( \. value) )
43
43
}
44
44
45
- final class Spies < PV : AnyObject > : NSObject , XCTWaiterDelegate {
46
- private( set) var objects : [ Int : PV ] = [ : ]
45
+ final class Spies < Entity : AnyObject > : NSObject , XCTWaiterDelegate {
46
+ private( set) var entities : [ Int : Entity ] = [ : ]
47
47
private( set) var expectations : [ ObjectIdentifier : ( XCTestExpectation , StaticString , UInt ) ] = [ : ]
48
48
49
49
subscript(
50
50
number: Int ,
51
51
file: StaticString = #file,
52
52
line: UInt = #line
53
- ) -> ( PV ) -> Void {
53
+ ) -> ( Entity ) -> Void {
54
54
let expectation = XCTestExpectation ( )
55
55
expectations [ ObjectIdentifier ( expectation) ] = ( expectation, file, line)
56
56
return { [ self ] in
57
- if let object = objects [ number] {
58
- XCTAssert ( object === $0, " Found view was overriden by another view " , file: file, line: line)
57
+ if let entity = entities [ number] {
58
+ XCTAssert ( entity === $0, " Found view was overriden by another view " , file: file, line: line)
59
59
}
60
- objects [ number] = $0
60
+ entities [ number] = $0
61
61
expectation. fulfill ( )
62
62
}
63
63
}
@@ -97,12 +97,10 @@ final class Spies<PV: AnyObject>: NSObject, XCTWaiterDelegate {
97
97
98
98
extension Collection {
99
99
subscript( safe index: Index , file: StaticString = #file, line: UInt = #line) -> Element ? {
100
- get {
101
- guard indices. contains ( index) else {
102
- XCTFail ( " Index \( index) is out of bounds " , file: file, line: line)
103
- return nil
104
- }
105
- return self [ index]
100
+ guard indices. contains ( index) else {
101
+ XCTFail ( " Index \( index) is out of bounds " , file: file, line: line)
102
+ return nil
106
103
}
104
+ return self [ index]
107
105
}
108
106
}
0 commit comments