Robert Payne 10 жил өмнө
parent
commit
298472bb0b
1 өөрчлөгдсөн 22 нэмэгдсэн , 0 устгасан
  1. 22 0
      Tests/Tests.swift

+ 22 - 0
Tests/Tests.swift

@@ -227,4 +227,26 @@ class SnapKitTests: XCTestCase {
         
     }
     
+    func testSizeConstraints() {
+        let view = View()
+        self.container.addSubview(view)
+        
+        view.snp_makeConstraints { (make) -> Void in
+            make.size.equalTo(CGSizeMake(50, 50))
+            make.left.top.equalTo(self.container)
+        }
+        
+        XCTAssertEqual(view.snp_constraints.count, 2, "Should have 2 constraints")
+        
+        XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints")
+        
+        
+        let constraints = view.snp_constraints as! [NSLayoutConstraint]
+        
+        XCTAssertEqual(constraints[0].firstAttribute, NSLayoutAttribute.Width, "Should be width")
+        XCTAssertEqual(constraints[1].firstAttribute, NSLayoutAttribute.Height, "Should be height")
+        XCTAssertEqual(constraints[0].constant, 50, "Should be 50")
+        XCTAssertEqual(constraints[1].constant, 50, "Should be 50")
+    }
+    
 }