@@ -112,6 +112,22 @@ class CoordinateFieldTests: KIFSpec {
112112 expect ( field. textField. accessibilityLabel) . to ( equal ( " Coordinate " ) )
113113 }
114114
115+ it ( " should set the text later with zero seconds specified " ) {
116+ let field = CoordinateField ( latitude: true , text: nil , label: " Coordinate " , delegate: nil , scheme: MAGEScheme . scheme ( ) )
117+ view. addSubview ( field) ;
118+ field. autoPinEdge ( toSuperviewEdge: . left) ;
119+ field. autoPinEdge ( toSuperviewEdge: . right) ;
120+ field. autoAlignAxis ( toSuperviewAxis: . horizontal) ;
121+ expect ( field. isHidden) . to ( beFalse ( ) ) ;
122+ expect ( field. textField. text) . to ( equal ( " " ) )
123+ expect ( field. text) . to ( equal ( " " ) )
124+ field. text = " 705600N "
125+ expect ( field. textField. text) . to ( equal ( " 70° 56' 00 \" N " ) )
126+ expect ( field. text) . to ( equal ( " 70° 56' 00 \" N " ) )
127+ expect ( field. textField. label. text) . to ( equal ( " Coordinate " ) )
128+ expect ( field. textField. accessibilityLabel) . to ( equal ( " Coordinate " ) )
129+ }
130+
115131 it ( " should enable and disable the field " ) {
116132 let field = CoordinateField ( latitude: true , text: nil , label: " Coordinate " , delegate: nil , scheme: MAGEScheme . scheme ( ) )
117133 view. addSubview ( field) ;
@@ -200,6 +216,41 @@ class CoordinateFieldTests: KIFSpec {
200216 expect ( delegate. changedValue) . to ( equal ( 0.5 ) )
201217 }
202218
219+ it ( " should edit the field with zero seconds specified and notify the delegate " ) {
220+ class MockCoordinateFieldDelegate : NSObject , CoordinateFieldDelegate {
221+ var fieldChangedCalled = false ;
222+ var changedValue : CLLocationDegrees ?
223+ var changedField : CoordinateField ?
224+ func fieldValueChanged( coordinate: CLLocationDegrees , field: CoordinateField ) {
225+ fieldChangedCalled = true
226+ changedValue = coordinate
227+ changedField = field
228+ }
229+ }
230+
231+ let delegate = MockCoordinateFieldDelegate ( )
232+ let field = CoordinateField ( latitude: true , text: nil , label: " Coordinate " , delegate: delegate, scheme: MAGEScheme . scheme ( ) )
233+ view. addSubview ( field) ;
234+ field. autoPinEdge ( toSuperviewEdge: . left) ;
235+ field. autoPinEdge ( toSuperviewEdge: . right) ;
236+ field. autoAlignAxis ( toSuperviewAxis: . horizontal) ;
237+ expect ( field. isHidden) . to ( beFalse ( ) ) ;
238+ expect ( field. textField. text) . to ( equal ( " " ) )
239+ expect ( field. text) . to ( equal ( " " ) )
240+ tester ( ) . waitForView ( withAccessibilityLabel: " Coordinate " )
241+ tester ( ) . tapView ( withAccessibilityLabel: " Coordinate " )
242+ expect ( field. isEditing) . to ( beTrue ( ) )
243+ tester ( ) . enterText ( intoCurrentFirstResponder: " 705600N " )
244+ expect ( field. textField. text) . to ( equal ( " 70° 56' 00 \" N " ) )
245+ expect ( field. text) . to ( equal ( " 70° 56' 00 \" N " ) )
246+ expect ( field. textField. label. text) . to ( equal ( " Coordinate " ) )
247+ expect ( field. textField. accessibilityLabel) . to ( equal ( " Coordinate " ) )
248+ field. resignFirstResponder ( )
249+ expect ( field. isEditing) . to ( beFalse ( ) )
250+ expect ( delegate. fieldChangedCalled) . to ( beTrue ( ) )
251+ expect ( delegate. changedValue) . to ( beCloseTo ( 70.9333 ) )
252+ }
253+
203254 it ( " should not start clearing text if multiple directions are entered " ) {
204255 class MockCoordinateFieldDelegate : NSObject , CoordinateFieldDelegate {
205256 var fieldChangedCalled = false ;
0 commit comments