Skip to content

Commit

Permalink
Improve pragma marks and test method ordering (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-cfuller authored Feb 5, 2024
1 parent f933193 commit cfa2ce9
Showing 1 changed file with 38 additions and 32 deletions.
70 changes: 38 additions & 32 deletions Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,39 @@ final class UIViewAutoLayoutTests: XCTestCase {

// MARK: - Size

func testSizeConstraintsWithSize() {

// GIVEN

let view: UIView = .init()

// WHEN

let sizeConstraints1: [NSLayoutConstraint] = view.sizeConstraints()

// THEN

expect(sizeConstraints1.count) == 2
expect(sizeConstraints1[0].firstAttribute) == .width
expect(sizeConstraints1[0].constant) == 0
expect(sizeConstraints1[1].firstAttribute) == .height
expect(sizeConstraints1[1].constant) == 0

// WHEN

let sizeConstraints2: [NSLayoutConstraint] = view.sizeConstraints(.init(width: 10, height: 20))

// THEN

expect(sizeConstraints2.count) == 2
expect(sizeConstraints2[0].firstAttribute) == .width
expect(sizeConstraints2[0].constant) == 10
expect(sizeConstraints2[1].firstAttribute) == .height
expect(sizeConstraints2[1].constant) == 20
}

// MARK: - Width

func testWidthConstraintIsRelationToConstant() {

// GIVEN
Expand Down Expand Up @@ -225,6 +258,8 @@ final class UIViewAutoLayoutTests: XCTestCase {
expect(widthConstraint2.constant) == width2
}

// MARK: - Height

func testHeightConstraintIsRelationToConstant() {

// GIVEN
Expand Down Expand Up @@ -294,38 +329,7 @@ final class UIViewAutoLayoutTests: XCTestCase {
expect(heightConstraint2.constant) == height2
}

func testSizeConstraintsWithSize() {

// GIVEN

let view: UIView = .init()

// WHEN

let sizeConstraints1: [NSLayoutConstraint] = view.sizeConstraints()

// THEN

expect(sizeConstraints1.count) == 2
expect(sizeConstraints1[0].firstAttribute) == .width
expect(sizeConstraints1[0].constant) == 0
expect(sizeConstraints1[1].firstAttribute) == .height
expect(sizeConstraints1[1].constant) == 0

// WHEN

let sizeConstraints2: [NSLayoutConstraint] = view.sizeConstraints(.init(width: 10, height: 20))

// THEN

expect(sizeConstraints2.count) == 2
expect(sizeConstraints2[0].firstAttribute) == .width
expect(sizeConstraints2[0].constant) == 10
expect(sizeConstraints2[1].firstAttribute) == .height
expect(sizeConstraints2[1].constant) == 20
}

// MARK: - Aspect Ratio
// MARK: - Square

func testSquareConstraint() {

Expand All @@ -344,6 +348,8 @@ final class UIViewAutoLayoutTests: XCTestCase {
expect(constraint.relation) == .equal
}

// MARK: - Aspect Ratio

func testAspectRatioConstraintWithRatio() {

// GIVEN
Expand Down

0 comments on commit cfa2ce9

Please sign in to comment.