diff --git a/Sources/ViewInspection/Reflection/ReflectionNode.swift b/Sources/ViewInspection/Reflection/ReflectionNode.swift index 56f4a90..89bb8cb 100644 --- a/Sources/ViewInspection/Reflection/ReflectionNode.swift +++ b/Sources/ViewInspection/Reflection/ReflectionNode.swift @@ -31,7 +31,7 @@ extension ReflectionNode { tree.filter(CP.isValid).map(CP.init).filter(filter) } - func one(_ t: AnyInspectable = .some, _ filter: (CP) -> Bool = { _ in true }) throws -> CP { + @discardableResult func one(_ t: AnyInspectable = .some, _ filter: (CP) -> Bool = { _ in true }) throws -> CP { let items = all(t, filter) if items.count != 1 { throw ViewInspectionError.wrongNumberOfItems diff --git a/Tests/ViewInspectionTests/PropertyWrappersTests.swift b/Tests/ViewInspectionTests/PropertyWrappersTests.swift index 272de0a..a5baa81 100644 --- a/Tests/ViewInspectionTests/PropertyWrappersTests.swift +++ b/Tests/ViewInspectionTests/PropertyWrappersTests.swift @@ -15,19 +15,19 @@ final class PropertyWrappersTests: XCTestCase {} XCTAssert(t[1].node.parent === t[0].node) } - func testState() { + func testState() throws { struct Dummy: View { @State private var x = 0 let body = EmptyView() } - XCTAssertEqual(Dummy().snap.all(.state).count, 1) + try Dummy().snap.one(.state) } - func testBinding() { + func testBinding() throws { struct Dummy: View { @Binding var x: Int let body = EmptyView() } - XCTAssertEqual(Dummy(x: .constant(1)).snap.all(.binding).count, 1) + try Dummy(x: .constant(1)).snap.one(.binding) } }