diff --git a/Source/ConstraintMakerPriortizable.swift b/Source/ConstraintMakerPriortizable.swift index 66aabe6..ef79448 100644 --- a/Source/ConstraintMakerPriortizable.swift +++ b/Source/ConstraintMakerPriortizable.swift @@ -31,8 +31,8 @@ public class ConstraintMakerPriortizable: ConstraintMakerFinalizable { @discardableResult - public func priority(_ amount: ConstraintPriority, offset: Float = 0) -> ConstraintMakerFinalizable { - self.description.priority = amount.value + offset + public func priority(_ amount: ConstraintPriority) -> ConstraintMakerFinalizable { + self.description.priority = amount.value return self } diff --git a/Tests/Tests.swift b/Tests/Tests.swift index 564be53..ed6df40 100644 --- a/Tests/Tests.swift +++ b/Tests/Tests.swift @@ -517,4 +517,27 @@ class SnapKitTests: XCTestCase { self.container.snp.setLabel("Hello World") } + func testPriorityShortcuts() { + let view = View() + self.container.addSubview(view) + + view.snp.remakeConstraints { make in + make.left.equalTo(1000.0).priority(.required) + } + XCTAssertEqual(self.container.snp_constraints.count, 1, "Should have 1 constraint") + XCTAssertEqual(self.container.snp_constraints.first?.priority, ConstraintPriority.required.value) + + view.snp.remakeConstraints { make in + make.left.equalTo(1000.0).priority(.low) + } + XCTAssertEqual(self.container.snp_constraints.count, 1, "Should have 1 constraint") + XCTAssertEqual(self.container.snp_constraints.first?.priority, ConstraintPriority.low.value) + + view.snp.remakeConstraints { make in + make.left.equalTo(1000.0).priority(ConstraintPriority.low.value + 1) + } + XCTAssertEqual(self.container.snp_constraints.count, 1, "Should have 1 constraint") + XCTAssertEqual(self.container.snp_constraints.first?.priority, ConstraintPriority.low.value + 1) + } + }