-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18fc248
commit 837abc9
Showing
2 changed files
with
100 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// | ||
// All Contributions by Match Group | ||
// | ||
// Copyright © 2023 Tinder (Match Group, LLC) | ||
// | ||
// Licensed under the Match Group Modified 3-Clause BSD License. | ||
// See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. | ||
// | ||
|
||
@testable import Layout | ||
import Nimble | ||
import XCTest | ||
|
||
@MainActor | ||
final class NSLayoutXAxisAnchorTests: XCTestCase { | ||
|
||
func testConstraintToXAnchor_withDefaults() { | ||
|
||
// GIVEN | ||
|
||
let viewA: UIView = .init() | ||
let viewB: UIView = .init() | ||
let expected: NSLayoutConstraint = viewA | ||
.centerX | ||
.constraint(equalTo: viewB.centerX) | ||
|
||
// WHEN | ||
|
||
let constraint: NSLayoutConstraint = viewA | ||
.centerX | ||
.constraint(to: viewB.centerX) | ||
|
||
// THEN | ||
|
||
expect(constraint).to(match(expected)) | ||
} | ||
|
||
func testConstraintToXAnchor_withConstant() { | ||
|
||
// GIVEN | ||
|
||
let viewA: UIView = .init() | ||
let viewB: UIView = .init() | ||
let expected: NSLayoutConstraint = viewA | ||
.centerX | ||
.constraint(equalTo: viewB.centerX, constant: 50) | ||
|
||
// WHEN | ||
|
||
let constraint: NSLayoutConstraint = viewA | ||
.centerX | ||
.constraint(is: .equal, to: viewB.centerX, constant: 50) | ||
|
||
// THEN | ||
|
||
expect(constraint).to(match(expected)) | ||
} | ||
|
||
func testConstraintToXAnchor_withGreaterThanOrEqualRelation() { | ||
|
||
// GIVEN | ||
|
||
let viewA: UIView = .init() | ||
let viewB: UIView = .init() | ||
let expected: NSLayoutConstraint = viewA | ||
.centerX | ||
.constraint(greaterThanOrEqualTo: viewB.centerX) | ||
|
||
// WHEN | ||
|
||
let constraint: NSLayoutConstraint = viewA | ||
.centerX | ||
.constraint(is: .greaterThanOrEqual, to: viewB.centerX) | ||
|
||
// THEN | ||
|
||
expect(constraint).to(match(expected)) | ||
} | ||
|
||
func testConstraintToXAnchor_withLessThanOrEqualRelation() { | ||
|
||
// GIVEN | ||
|
||
let viewA: UIView = .init() | ||
let viewB: UIView = .init() | ||
let expected: NSLayoutConstraint = viewA | ||
.centerX | ||
.constraint(lessThanOrEqualTo: viewB.centerX) | ||
|
||
// WHEN | ||
|
||
let constraint: NSLayoutConstraint = viewA | ||
.centerX | ||
.constraint(is: .lessThanOrEqual, to: viewB.centerX) | ||
|
||
// THEN | ||
|
||
expect(constraint).to(match(expected)) | ||
} | ||
} |