@@ -94,19 +94,29 @@ final class TSAlertControllerTests: XCTestCase {
9494 XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
9595 }
9696
97- func testTSAlertController_WhenInitalizedWithFourButtonsAndAutomaticAxis_ShouldSetCorrectActionsOrderAndCount( ) {
97+
98+ func testTSAlertController_WhenIntlaizedWithAlertStyle_ShouldSetDefaultConfiguration( ) {
9899 // given
99100 let alertController = TSAlertController (
100101 title: " The title of the alert " ,
101102 preferredStyle: . alert
102103 )
103104 let mockViewController = MockViewController ( )
104105
105- alertController. addAction ( . init( title: " Cancel " , style: . cancel) )
106+ // when
107+ mockViewController. present ( alertController, animated: true )
108+
109+ // then
110+ let config = alertController. configuration
111+ XCTAssertEqual ( config. enteringTransition, . fadeInAndScaleDown)
112+ XCTAssertEqual ( config. exitingTransition, . fadeOut)
113+ XCTAssertEqual ( config. headerAnimation, . none)
114+ XCTAssertEqual ( config. buttonGroupAnimation, . none)
115+ XCTAssertEqual ( config. prefersGrabberVisible, false )
116+ XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
106117 }
107118
108-
109- func testTSAlertController_WhenIntlaizedWithAlertStyle_ShouldSetDefaultConfiguration( ) {
119+ func testTSAlertController_WhenIntializedWithAlertStyle_ShouldSetDefaultViewConfiguration( ) {
110120 // given
111121 let alertController = TSAlertController (
112122 title: " The title of the alert " ,
@@ -118,16 +128,13 @@ final class TSAlertControllerTests: XCTestCase {
118128 mockViewController. present ( alertController, animated: true )
119129
120130 // then
121- let config = alertController. configuration
122- XCTAssertEqual ( config. enteringTransition, . fadeInAndScaleDown)
123- XCTAssertEqual ( config. exitingTransition, . fadeOut)
124- XCTAssertEqual ( config. headerAnimation, . none)
125- XCTAssertEqual ( config. buttonGroupAnimation, . none)
126- XCTAssertEqual ( config. prefersGrabberVisible, false )
131+ let viewConfig = alertController. viewConfiguration
132+ XCTAssertEqual ( viewConfig. size. width, . proportional( minimumRatio: 0.75 , maximumRatio: 0.75 ) )
133+ XCTAssertEqual ( viewConfig. spacing. keyboardSpacing, 100 )
127134 XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
128135 }
129136
130- func testTSAlertController_WhenIntializedWithAlertStyle_SouldSetEnforceCorrectConfiguration ( ) {
137+ func testTSAlertController_WhenIntializedWithAlertStyle_SouldSetCorrectConfigurationForcibly ( ) {
131138 // given
132139 let alertController = TSAlertController (
133140 title: " The title of the alert " ,
@@ -166,7 +173,7 @@ final class TSAlertControllerTests: XCTestCase {
166173 XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
167174 }
168175
169- func testTSAlertController_WhenIntilizedWithFloatinSheetStyle_ShouldSetEnforceCorrectConfiguration ( ) {
176+ func testTSAlertController_WhenInitializedWithFloatingSheetStyle_ShouldSetDefaultViewConfiguration ( ) {
170177 // given
171178 let alertController = TSAlertController (
172179 title: " The title of the alert " ,
@@ -178,15 +185,57 @@ final class TSAlertControllerTests: XCTestCase {
178185 mockViewController. present ( alertController, animated: true )
179186
180187 // then
181- XCTAssertTrue ( true )
188+ let viewConfig = alertController. viewConfiguration
189+ XCTAssertEqual ( viewConfig. size. width, . proportional( minimumRatio: 0.95 , maximumRatio: 0.95 ) )
190+ XCTAssertEqual ( viewConfig. spacing. keyboardSpacing, 20 )
182191 XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
183192 }
184193
185- func testTSAlertController_WhenIntializedWithAlertStyle_ShouldSetDefaultViewConfiguration ( ) {
194+ func testTSAlertController_WhenIntilizedWithFloatingSheetStyle_ShouldSetCorrectConfigurationForcibly ( ) {
186195 // given
187196 let alertController = TSAlertController (
188197 title: " The title of the alert " ,
189- preferredStyle: . alert
198+ preferredStyle: . floatingSheet
199+ )
200+ let mockViewController = MockViewController ( )
201+
202+ // when
203+ mockViewController. present ( alertController, animated: true )
204+
205+ // then
206+ let config = alertController. configuration
207+ XCTAssertFalse ( alertController. options. contains ( . stretchyDragging) )
208+ XCTAssertEqual ( config. prefersGrabberVisible, true )
209+ XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
210+ XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
211+ }
212+
213+ func testTSAlertController_WhenIntializedWithActionSheetStyle_ShouldSetDefaultCconfiguration( ) {
214+ // given
215+ let alertController = TSAlertController (
216+ title: " The title of the alert " ,
217+ preferredStyle: . actionSheet
218+ )
219+ let mockViewController = MockViewController ( )
220+
221+ // when
222+ mockViewController. present ( alertController, animated: true )
223+
224+ // then
225+ let config = alertController. configuration
226+ XCTAssertEqual ( config. enteringTransition, . slideUp)
227+ XCTAssertEqual ( config. exitingTransition, . slideDown)
228+ XCTAssertEqual ( config. headerAnimation, . none)
229+ XCTAssertEqual ( config. buttonGroupAnimation, . none)
230+ XCTAssertEqual ( config. prefersGrabberVisible, true )
231+ XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
232+ }
233+
234+ func testTSAlertController_WhenIntializedWithActionSheetStyle_ShouldSetDefaultViewConfiguration( ) {
235+ // given
236+ let alertController = TSAlertController (
237+ title: " The title of the alert " ,
238+ preferredStyle: . actionSheet
190239 )
191240 let mockViewController = MockViewController ( )
192241
@@ -195,12 +244,12 @@ final class TSAlertControllerTests: XCTestCase {
195244
196245 // then
197246 let viewConfig = alertController. viewConfiguration
198- XCTAssertEqual ( viewConfig. size. width, . proportional( minimumRatio: 0.75 , maximumRatio: 0.75 ) )
199- XCTAssertEqual ( viewConfig. spacing. keyboardSpacing, 100 )
247+ XCTAssertEqual ( viewConfig. size. width, . proportional( minimumRatio: 1.0 , maximumRatio: 1.0 ) )
248+ XCTAssertEqual ( viewConfig. spacing. keyboardSpacing, 0.0 )
200249 XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
201250 }
202251
203- func testTSAlertController_WhenInitializedWithFloatingSheetStyle_ShouldSetDefaultViewConfiguration ( ) {
252+ func testTSAlertController_WhenIntializedWithActionSheetStyle_ShouldSetCorrectConfigurationForcibly ( ) {
204253 // given
205254 let alertController = TSAlertController (
206255 title: " The title of the alert " ,
@@ -212,9 +261,10 @@ final class TSAlertControllerTests: XCTestCase {
212261 mockViewController. present ( alertController, animated: true )
213262
214263 // then
215- let viewConfig = alertController. viewConfiguration
216- XCTAssertEqual ( viewConfig. size. width, . proportional( minimumRatio: 0.95 , maximumRatio: 0.95 ) )
217- XCTAssertEqual ( viewConfig. spacing. keyboardSpacing, 20 )
264+ let config = alertController. configuration
265+ XCTAssertFalse ( alertController. options. contains ( . interactiveScaleAndDrag) )
266+ XCTAssertEqual ( config. prefersGrabberVisible, true )
267+ XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
218268 XCTAssertEqual ( mockViewController. presentViewControllerTarget, alertController)
219269 }
220270
0 commit comments