Skip to content

Commit e3dc3dc

Browse files
devkaranCTmpospese
authored andcommitted
CM-1012: UT in progress
1 parent 09a66f3 commit e3dc3dc

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Tests/YCoreUITests/Extensions/UIKit/UIView+constrainAspectRatioTests.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,37 @@ import XCTest
1010
@testable import YCoreUI
1111

1212
final class UIViewContrainAspectRatioTests: XCTestCase {
13+
func testSimple() {
14+
let sut = makeSUT()
15+
XCTAssert(sut.translatesAutoresizingMaskIntoConstraints)
16+
sut.frame = CGRect(x: 0, y: 0, width: 100, height: 500)
17+
sut.constrainAspectRatio(0.5)
18+
// XCTAssertEqual(sut.frame.height, sut.frame.width * 0.5)
19+
}
1320

21+
func testOffset() {
22+
let sut = makeSUT()
23+
var randomOffset: CGFloat = CGFloat.random(in: 0..<500)
24+
let constraint = sut.constrainAspectRatio(0.5, offset: randomOffset)
25+
XCTAssertEqual(constraint.constant, randomOffset)
26+
}
27+
28+
func testPriority() {
29+
let sut = makeSUT()
30+
let randomPriority: UILayoutPriority = UILayoutPriority(Float.random(in: 1...1000))
31+
let constraint = sut.constrainAspectRatio(0.5, priority: randomPriority)
32+
XCTAssertEqual(constraint.priority, randomPriority)
33+
}
1434
}
35+
36+
private extension UIViewContrainAspectRatioTests {
37+
func makeSUT(
38+
file: StaticString = #filePath,
39+
line: UInt = #line
40+
) -> UIView {
41+
let sut = UIView()
42+
trackForMemoryLeak(sut, file: file, line: line)
43+
return sut
44+
}
45+
}
46+

0 commit comments

Comments
 (0)