Skip to content

Commit

Permalink
Code coverage bump (#6)
Browse files Browse the repository at this point in the history
* increasing code coverage to 100%
* bumped podspec
  • Loading branch information
anafpf authored and pedrommcarrasco committed Jun 9, 2018
1 parent cb2c0ec commit 372f2a6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Constrictor.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pod::Spec.new do |s|
s.swift_version = "4.1"
s.static_framework = true
s.name = "Constrictor"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "🐍 AutoLayout's µFramework"

s.description = "(Boe) Constrictor's AutoLayout µFramework with the goal of simplying your constraints by reducing the amount of code you have to write."
Expand Down
10 changes: 6 additions & 4 deletions Constrictor/Constrictor/Enumerations/ConstrictorAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ extension ConstrictorAttribute {
*/

func itemLayoutAttribute(for item: Constrictable?) -> (item: Any?, layoutAttribute: NSLayoutAttribute) {

var itemLayoutAttributeTuple: (item: Any?, layoutAttribute: NSLayoutAttribute) = (nil, .notAnAttribute)

if let view = item as? UIView {
return itemLayoutAttribute(for: view)
itemLayoutAttributeTuple = itemLayoutAttribute(for: view)

} else if let viewController = item as? UIViewController {
return itemLayoutAttribute(for: viewController)
itemLayoutAttributeTuple = itemLayoutAttribute(for: viewController)

} else if let layoutGuide = item as? UILayoutGuide {
return itemLayoutAttribute(for: layoutGuide)
itemLayoutAttributeTuple = itemLayoutAttribute(for: layoutGuide)
}

return (item, .notAnAttribute)
return itemLayoutAttributeTuple
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ class UIViewConstrictorCenterTests: XCTestCase, ConstraintTestable {
testConstraint(centerXConstraint, constant: Constants.constant, multiplier: Constants.multiplier)
testConstraint(centerYConstraint, constant: Constants.constant, multiplier: Constants.multiplier)
}

func testConstrictCenterInViewControllerWithoutGuides() {

// Setup
viewController.view.addSubview(aView)
aView.constrictCenterInViewController(viewController, withinGuides: false)

// Tests
let centerXConstraints = viewController.view.findConstraints(for: .centerX, relatedTo: aView)
let centerYConstraints = viewController.view.findConstraints(for: .centerY, relatedTo: aView)

XCTAssertEqual(centerXConstraints.count, 1)
XCTAssertEqual(centerYConstraints.count, 1)

guard let centerXConstraint = centerXConstraints.first,
let centerYConstraint = centerYConstraints.first else { return XCTFail() }

testConstraint(centerXConstraint)
testConstraint(centerYConstraint)
}

// MARK: Test - constrictCenterInSuperview(_ relation: NSLayoutRelation = .equal, constant: CGFloat = 0.0, ...
func testConstrictCenterInSuperViewWithConstantMultiplier() {
Expand Down

0 comments on commit 372f2a6

Please sign in to comment.