Skip to content

Commit ae3852c

Browse files
committed
Add tests for setGap with .column and .all directions
1 parent 9dfd4c4 commit ae3852c

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

Tests/FlexLayoutTests/WidthSizeContentTests.swift

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class WidthSizeContentTests: XCTestCase {
1919
var rootFlexContainer: UIView!
2020
var aView: UIView!
2121
var bView: UIView!
22+
var cView: UIView!
2223

2324
override func setUp() {
2425
super.setUp()
@@ -31,6 +32,7 @@ final class WidthSizeContentTests: XCTestCase {
3132

3233
aView = UIView()
3334
bView = UIView()
35+
cView = UIView()
3436
}
3537

3638
func test_basis_adjust_aView_size_and_position() {
@@ -162,7 +164,7 @@ final class WidthSizeContentTests: XCTestCase {
162164
XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 200.0))
163165
}
164166

165-
func test_gap() {
167+
func test_gap_in_row_direction() {
166168
rootFlexContainer.flex.direction(.row).define { flex in
167169
flex.addItem(aView).height(100).width(100)
168170
flex.addItem(bView).height(100).width(100)
@@ -174,4 +176,35 @@ final class WidthSizeContentTests: XCTestCase {
174176
rootFlexContainer.flex.layout()
175177
XCTAssertEqual(bView.frame, CGRect(x: 150.0, y: 0.0, width: 100.0, height: 100.0))
176178
}
179+
180+
func test_gap_in_column_direction() {
181+
rootFlexContainer.flex.direction(.column).define { flex in
182+
flex.addItem(aView).height(100).width(100)
183+
flex.addItem(bView).height(100).width(100)
184+
flex.alignItems(.start)
185+
186+
flex.setGap(.column, 50)
187+
}
188+
189+
rootFlexContainer.flex.layout()
190+
XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 150.0, width: 100.0, height: 100.0))
191+
}
192+
193+
func test_gap_in_all_direction() {
194+
rootFlexContainer.flex.direction(.column).define { flex in
195+
flex.addItem(aView).height(100).width(100)
196+
flex.addItem(bView).height(100).width(100)
197+
flex.addItem().direction(.row).define { flex in
198+
flex.addItem(cView).height(100).width(100)
199+
}
200+
flex.alignItems(.start)
201+
202+
flex.setGap(.all, 50)
203+
}
204+
205+
rootFlexContainer.flex.layout()
206+
207+
XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 150.0, width: 100.0, height: 100.0))
208+
XCTAssertEqual(cView.frame, CGRect(x: 150.0, y: 0.0, width: 100.0, height: 100.0))
209+
}
177210
}

0 commit comments

Comments
 (0)