Skip to content

Commit

Permalink
Improve tests (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-cfuller authored Mar 7, 2024
1 parent 79008fe commit 76a29aa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class UIViewLayoutItemTests: XCTestCase {

// THEN

expect(view.superviewConstraints(UIView())).to(beEmpty())
expect(view.superviewConstraints(view)).to(beEmpty())
}

func testLayoutBoundary() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ final class ViewLayoutItemTests: XCTestCase {

// GIVEN

let superview: UIView = .init()
let view: UIView = .init()
let constraint: NSLayoutConstraint = .init()
var layoutItems: [LayoutItem] = []
Expand All @@ -36,12 +35,12 @@ final class ViewLayoutItemTests: XCTestCase {

// WHEN

let superviewConstraints: [NSLayoutConstraint] = viewLayoutItem.superviewConstraints(superview)
let superviewConstraints: [NSLayoutConstraint] = viewLayoutItem.superviewConstraints(viewLayoutItem)

// THEN

expect(superviewConstraints === [constraint]) == true
expect(layoutItems === [superview]) == true
expect(layoutItems === [viewLayoutItem]) == true
}

func testLayoutBoundary() {
Expand Down
8 changes: 4 additions & 4 deletions Tests/LayoutTests/LayoutItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -730,15 +730,15 @@ final class LayoutItemTests: XCTestCase {

// THEN

expect(item.superviewConstraints(view)).to(throwAssertion())
expect(item.superviewConstraints(item)).to(throwAssertion())

// WHEN

superview.addSubview(view)

// THEN

expect(item.superviewConstraints(view).count) == 4
expect(item.superviewConstraints(item).count) == 4
}

func testToMarginsInsetsPriorityDirectional() {
Expand Down Expand Up @@ -882,15 +882,15 @@ final class LayoutItemTests: XCTestCase {

// THEN

expect(item.superviewConstraints(view)).to(throwAssertion())
expect(item.superviewConstraints(item)).to(throwAssertion())

// WHEN

superview.addSubview(view)

// THEN

expect(item.superviewConstraints(view).count) == 4
expect(item.superviewConstraints(item).count) == 4
}

func testToSafeAreaInsetsPriorityDirectional() {
Expand Down
14 changes: 6 additions & 8 deletions Tests/LayoutTests/Swift/CollectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ final class CollectionTests: XCTestCase {
// GIVEN

let view1: UIView = .init()
let subview1: UIView = .init()
let widthConstraint1: NSLayoutConstraint = .init(
item: subview1,
item: view1,
attribute: .width,
relatedBy: .equal,
toItem: nil,
Expand All @@ -30,20 +29,19 @@ final class CollectionTests: XCTestCase {
constant: 100
)
let heightConstraint1: NSLayoutConstraint = .init(
item: subview1,
item: view1,
attribute: .height,
relatedBy: .equal,
toItem: nil,
attribute: .notAnAttribute,
multiplier: 1,
constant: 100
)
let layout1: Layout = .init(view1, subview1)
let layout1: Layout = .init(view1)

let view2: UIView = .init()
let subview2: UIView = .init()
let widthConstraint2: NSLayoutConstraint = .init(
item: subview1,
item: view1,
attribute: .width,
relatedBy: .equal,
toItem: nil,
Expand All @@ -52,15 +50,15 @@ final class CollectionTests: XCTestCase {
constant: 100
)
let heightConstraint2: NSLayoutConstraint = .init(
item: subview2,
item: view2,
attribute: .height,
relatedBy: .equal,
toItem: nil,
attribute: .notAnAttribute,
multiplier: 1,
constant: 100
)
let layout2: Layout = .init(view2, subview2)
let layout2: Layout = .init(view2)

let layouts: [Layout] = [layout1, layout2]

Expand Down

0 comments on commit 76a29aa

Please sign in to comment.