@@ -21,13 +21,13 @@ final class InsetTests: XCTestCase {
2121
2222 override func setUp( ) {
2323 super. setUp ( )
24-
24+
2525 viewController = UIViewController ( )
26-
26+
2727 rootFlexContainer = UIView ( )
2828 rootFlexContainer. frame = CGRect ( x: 0 , y: 0 , width: 400 , height: 400 )
2929 viewController. view. addSubview ( rootFlexContainer)
30-
30+
3131 aView = UIView ( )
3232 }
3333
@@ -78,4 +78,42 @@ final class InsetTests: XCTestCase {
7878 rootFlexContainer. flex. layout ( )
7979 XCTAssertEqual ( aView. frame, CGRect ( x: 0.0 , y: 10.0 , width: 400.0 , height: 400.0 ) )
8080 }
81+
82+ func test_adjust_the_aView_size_absolute_position_with_left_right( ) {
83+ rootFlexContainer. flex. define { flex in
84+ flex. addItem ( aView) . position ( . absolute) . left ( 10 ) . right ( 10 ) . width ( 300 ) . height ( 200 )
85+ }
86+
87+ rootFlexContainer. flex. layout ( )
88+ XCTAssertEqual ( aView. frame, CGRect ( x: 10.0 , y: 0.0 , width: 300.0 , height: 200.0 ) )
89+ }
90+
91+ func test_adjust_the_aView_size_absolute_position_with_right( ) {
92+ rootFlexContainer. flex. define { flex in
93+ flex. addItem ( aView) . position ( . absolute) . left ( 10 ) . right ( 10 ) . width ( 300 ) . height ( 200 )
94+ }
95+
96+ // Later reset the aspectRatio
97+ aView. flex. left ( 0 )
98+ rootFlexContainer. flex. layout ( )
99+ XCTAssertEqual ( aView. frame, CGRect ( x: 0.0 , y: 0.0 , width: 300.0 , height: 200.0 ) )
100+ }
101+
102+ func test_adjust_the_aView_size_absolute_position_with_horizontally_vertically( ) {
103+ rootFlexContainer. flex. define { flex in
104+ flex. addItem ( aView) . position ( . absolute) . horizontally ( 15 ) . vertically ( 20 )
105+ }
106+
107+ rootFlexContainer. flex. layout ( )
108+ XCTAssertEqual ( aView. frame, CGRect ( x: 15.0 , y: 20.0 , width: 370.0 , height: 360.0 ) )
109+ }
110+
111+ func test_adjust_the_aView_size_absolute_position_with_horizontally_all( ) {
112+ rootFlexContainer. flex. define { flex in
113+ flex. addItem ( aView) . position ( . absolute) . all ( 45 )
114+ }
115+
116+ rootFlexContainer. flex. layout ( )
117+ XCTAssertEqual ( aView. frame, CGRect ( x: 45.0 , y: 45.0 , width: 310.0 , height: 310.0 ) )
118+ }
81119}
0 commit comments