mirror of https://github.com/SnapKit/SnapKit
Add more tests
This commit is contained in:
parent
a1820376f6
commit
218efd7d3b
|
@ -74,8 +74,6 @@ class SnapKitTests: XCTestCase {
|
||||||
self.container.addSubview(v1)
|
self.container.addSubview(v1)
|
||||||
self.container.addSubview(v2)
|
self.container.addSubview(v2)
|
||||||
|
|
||||||
print(v1)
|
|
||||||
|
|
||||||
v1.snp.makeConstraints { (make) -> Void in
|
v1.snp.makeConstraints { (make) -> Void in
|
||||||
make.top.equalTo(v2.snp.top).offset(50)
|
make.top.equalTo(v2.snp.top).offset(50)
|
||||||
make.left.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() {
|
func testSizeConstraints() {
|
||||||
let view = View()
|
let view = View()
|
||||||
self.container.addSubview(view)
|
self.container.addSubview(view)
|
||||||
|
@ -246,6 +263,23 @@ class SnapKitTests: XCTestCase {
|
||||||
XCTAssertEqual(constraints[1].constant, 50, "Should be 50")
|
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() {
|
func testConstraintIdentifier() {
|
||||||
let identifier = "Test-Identifier"
|
let identifier = "Test-Identifier"
|
||||||
let view = View()
|
let view = View()
|
||||||
|
|
Loading…
Reference in New Issue