mirror of https://github.com/SnapKit/SnapKit
Updated tests
This commit is contained in:
parent
b7eb62fba0
commit
48eed7ffeb
|
@ -35,11 +35,16 @@ class SnapTests: XCTestCase {
|
||||||
make.left.equalTo(v2.snp_top).offset(50)
|
make.left.equalTo(v2.snp_top).offset(50)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 2, "Should have 2 constraints installed")
|
||||||
|
|
||||||
v2.snp_makeConstraints { (make) -> Void in
|
v2.snp_makeConstraints { (make) -> Void in
|
||||||
make.edges.equalTo(v1)
|
make.edges.equalTo(v1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 6, "Should have 6 constraints installed")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUpdateConstraints() {
|
func testUpdateConstraints() {
|
||||||
|
@ -53,11 +58,16 @@ class SnapTests: XCTestCase {
|
||||||
make.left.equalTo(v2.snp_top).offset(50)
|
make.left.equalTo(v2.snp_top).offset(50)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 2, "Should have 2 constraints installed")
|
||||||
|
|
||||||
v1.snp_updateConstraints { (make) -> Void in
|
v1.snp_updateConstraints { (make) -> Void in
|
||||||
make.top.equalTo(v2.snp_top).offset(15)
|
make.top.equalTo(v2.snp_top).offset(15)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 2, "Should still have 2 constraints installed")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRemakeConstraints() {
|
func testRemakeConstraints() {
|
||||||
|
@ -71,11 +81,16 @@ class SnapTests: XCTestCase {
|
||||||
make.left.equalTo(v2.snp_top).offset(50)
|
make.left.equalTo(v2.snp_top).offset(50)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 2, "Should have 2 constraints installed")
|
||||||
|
|
||||||
v1.snp_remakeConstraints { (make) -> Void in
|
v1.snp_remakeConstraints { (make) -> Void in
|
||||||
make.edges.equalTo(v2)
|
make.edges.equalTo(v2)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 4, "Should have 4 constraints installed")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRemoveConstraints() {
|
func testRemoveConstraints() {
|
||||||
|
@ -89,8 +104,40 @@ class SnapTests: XCTestCase {
|
||||||
make.left.equalTo(v2.snp_top).offset(50)
|
make.left.equalTo(v2.snp_top).offset(50)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 2, "Should have 2 constraints installed")
|
||||||
|
|
||||||
v1.snp_removeConstraints()
|
v1.snp_removeConstraints()
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 0, "Should have 0 constraints installed")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func testPrepareConstraints() {
|
||||||
|
let v1 = UIView()
|
||||||
|
let v2 = UIView()
|
||||||
|
self.container.addSubview(v1)
|
||||||
|
self.container.addSubview(v2)
|
||||||
|
|
||||||
|
let constraints = v1.snp_prepareConstraints { (make) -> Void in
|
||||||
|
make.edges.equalTo(v2)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 0, "Should have 0 constraints installed")
|
||||||
|
|
||||||
|
for constraint in constraints {
|
||||||
|
constraint.install()
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 4, "Should have 4 constraints installed")
|
||||||
|
|
||||||
|
for constraint in constraints {
|
||||||
|
constraint.uninstall()
|
||||||
|
}
|
||||||
|
|
||||||
|
XCTAssertEqual(self.container.constraints().count, 0, "Should have 0 constraints installed")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue