Skip to content

Commit

Permalink
Improve UIView Auto Layout tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-cfuller committed Feb 13, 2024
1 parent 9d33ee2 commit 98cc327
Show file tree
Hide file tree
Showing 2 changed files with 418 additions and 162 deletions.
9 changes: 6 additions & 3 deletions Tests/LayoutTests/Support/NimbleMatchers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ extension XCTestCase {
// swiftlint:disable cyclomatic_complexity

@MainActor
internal func match(_ expectedConstraint: NSLayoutConstraint) -> Matcher<NSLayoutConstraint> {
internal func match(
_ expectedConstraint: NSLayoutConstraint,
isActive: Bool? = nil // swiftlint:disable:this discouraged_optional_boolean
) -> Matcher<NSLayoutConstraint> {
// swiftlint:disable:next closure_body_length
Matcher { expression in
guard let constraint: NSLayoutConstraint = try expression.evaluate()
else { return MatcherResult(status: .fail, message: .expectedTo("not be nil, got <nil>")) }
guard constraint.isActive == expectedConstraint.isActive
guard constraint.isActive == isActive ?? expectedConstraint.isActive
else {
let message: String = """
match `isActive` <\(expectedConstraint.isActive)>, \
match `isActive` <\(isActive ?? expectedConstraint.isActive)>, \
got <\(constraint.isActive)>
"""
return MatcherResult(status: .fail, message: .expectedTo(message))
Expand Down
Loading

0 comments on commit 98cc327

Please sign in to comment.