From 218efd7d3baac5befae4811b51d829143a1d939a Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Sat, 6 Aug 2016 23:24:43 +1200 Subject: [PATCH] Add more tests --- Tests/Tests.swift | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Tests/Tests.swift b/Tests/Tests.swift index be74ad0..6e185ad 100644 --- a/Tests/Tests.swift +++ b/Tests/Tests.swift @@ -74,8 +74,6 @@ class SnapKitTests: XCTestCase { self.container.addSubview(v1) self.container.addSubview(v2) - print(v1) - v1.snp.makeConstraints { (make) -> Void in make.top.equalTo(v2.snp.top).offset(50) make.left.equalTo(v2.snp.top).offset(50) @@ -224,6 +222,25 @@ class SnapKitTests: XCTestCase { } + func testEdgeConstraints() { + let view = View() + self.container.addSubview(view) + + view.snp.makeConstraints { (make) -> Void in + make.edges.equalTo(self.container).offset(50.0) + } + + XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints") + + + let constraints = self.container.snp_constraints as! [NSLayoutConstraint] + + XCTAssertEqual(constraints[0].constant, 50, "Should be 50") + XCTAssertEqual(constraints[1].constant, 50, "Should be 50") + XCTAssertEqual(constraints[2].constant, 50, "Should be 50") + XCTAssertEqual(constraints[3].constant, 50, "Should be 50") + } + func testSizeConstraints() { let view = View() self.container.addSubview(view) @@ -246,6 +263,23 @@ class SnapKitTests: XCTestCase { XCTAssertEqual(constraints[1].constant, 50, "Should be 50") } + func testCenterConstraints() { + let view = View() + self.container.addSubview(view) + + view.snp.makeConstraints { (make) -> Void in + make.center.equalTo(self.container).offset(50.0) + } + + XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints") + + + let constraints = self.container.snp_constraints as! [NSLayoutConstraint] + + XCTAssertEqual(constraints[0].constant, 50, "Should be 50") + XCTAssertEqual(constraints[1].constant, 50, "Should be 50") + } + func testConstraintIdentifier() { let identifier = "Test-Identifier" let view = View()