Skip to content

Commit 49d5607

Browse files
committed
Add tests for getGap
1 parent 93433c3 commit 49d5607

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

Tests/FlexLayoutTests/WidthSizeContentTests.swift

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ final class WidthSizeContentTests: XCTestCase {
164164
XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 200.0))
165165
}
166166

167-
func test_gap_in_row_direction() {
167+
func test_set_gap_in_row_direction() {
168168
rootFlexContainer.flex.direction(.row).define { flex in
169169
flex.addItem(aView).height(100).width(100)
170170
flex.addItem(bView).height(100).width(100)
@@ -177,7 +177,7 @@ final class WidthSizeContentTests: XCTestCase {
177177
XCTAssertEqual(bView.frame, CGRect(x: 150.0, y: 0.0, width: 100.0, height: 100.0))
178178
}
179179

180-
func test_gap_in_column_direction() {
180+
func test_set_gap_in_column_direction() {
181181
rootFlexContainer.flex.direction(.column).define { flex in
182182
flex.addItem(aView).height(100).width(100)
183183
flex.addItem(bView).height(100).width(100)
@@ -190,7 +190,7 @@ final class WidthSizeContentTests: XCTestCase {
190190
XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 150.0, width: 100.0, height: 100.0))
191191
}
192192

193-
func test_gap_in_all_direction() {
193+
func test_set_gap_in_all_direction() {
194194
rootFlexContainer.flex.direction(.column).define { flex in
195195
flex.addItem(aView).height(100).width(100)
196196
flex.addItem(bView).height(100).width(100)
@@ -207,4 +207,55 @@ final class WidthSizeContentTests: XCTestCase {
207207
XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 150.0, width: 100.0, height: 100.0))
208208
XCTAssertEqual(cView.frame, CGRect(x: 150.0, y: 0.0, width: 100.0, height: 100.0))
209209
}
210+
211+
func test_get_gap_in_row_direction() {
212+
rootFlexContainer.flex.direction(.row).define { flex in
213+
flex.addItem(aView).height(100).width(100)
214+
flex.addItem(bView).height(100).width(100)
215+
flex.alignItems(.start)
216+
217+
flex.setGap(.row, 20)
218+
}
219+
220+
rootFlexContainer.flex.layout()
221+
222+
let rowGap = rootFlexContainer.flex.getGap(.row)
223+
224+
XCTAssertEqual(rowGap, 20)
225+
}
226+
227+
func test_get_gap_in_column_direction() {
228+
rootFlexContainer.flex.direction(.column).define { flex in
229+
flex.addItem(aView).height(100).width(100)
230+
flex.addItem(bView).height(100).width(100)
231+
flex.alignItems(.start)
232+
233+
flex.setGap(.column, 20)
234+
}
235+
236+
rootFlexContainer.flex.layout()
237+
238+
let columnGap = rootFlexContainer.flex.getGap(.column)
239+
240+
XCTAssertEqual(columnGap, 20)
241+
}
242+
243+
func test_get_gap_in_all_direction() {
244+
rootFlexContainer.flex.direction(.column).define { flex in
245+
flex.addItem(aView).height(100).width(100)
246+
flex.addItem(bView).height(100).width(100)
247+
flex.addItem().direction(.row).define { flex in
248+
flex.addItem(cView).height(100).width(100)
249+
}
250+
flex.alignItems(.start)
251+
252+
flex.setGap(.all, 20)
253+
}
254+
255+
rootFlexContainer.flex.layout()
256+
257+
let allGap = rootFlexContainer.flex.getGap(.all)
258+
259+
XCTAssertEqual(allGap, 20)
260+
}
210261
}

0 commit comments

Comments
 (0)