Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar Otasevic committed Sep 9, 2024
1 parent bcd2331 commit 740c72a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/ViewInspection/Reflection/ReflectionNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extension ReflectionNode {
tree.filter(CP.isValid).map(CP.init).filter(filter)
}

func one<CP: ReflectionElement>(_ t: AnyInspectable<CP> = .some, _ filter: (CP) -> Bool = { _ in true }) throws -> CP {
@discardableResult func one<CP: ReflectionElement>(_ t: AnyInspectable<CP> = .some, _ filter: (CP) -> Bool = { _ in true }) throws -> CP {
let items = all(t, filter)
if items.count != 1 {
throw ViewInspectionError.wrongNumberOfItems
Expand Down
8 changes: 4 additions & 4 deletions Tests/ViewInspectionTests/PropertyWrappersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 740c72a

Please sign in to comment.