@@ -67,24 +67,15 @@ describe('geocoder', function() {
67
67
) ;
68
68
} ) ;
69
69
70
- it ( 'fallbacks to google api when not available ' , async function ( ) {
70
+ it ( 'always fallbacks to google api on error ' , async function ( ) {
71
71
const position = { lat : 1.234 , lng : 4.567 } ;
72
- RNGeocoder . geocodePosition = sinon . stub ( ) . returns ( Promise . reject ( { code : 'NOT_AVAILABLE' } ) ) ;
72
+ RNGeocoder . geocodePosition = sinon . stub ( ) . returns ( Promise . reject ( null ) ) ;
73
73
Geocoder . fallbackToGoogle ( 'myGoogleMapsAPIKey' ) ;
74
74
const ret = await Geocoder . geocodePosition ( position ) ;
75
75
expect ( GoogleApi . geocodePosition ) . to . have . been . calledWith ( 'myGoogleMapsAPIKey' , position ) ;
76
76
expect ( ret ) . to . eql ( 'google' ) ;
77
77
} ) ;
78
78
79
- it ( 'does not fallback to google api on error' , function ( ) {
80
- const position = { lat : 1.234 , lng : 4.567 } ;
81
- RNGeocoder . geocodePosition = sinon . stub ( ) . returns ( Promise . reject ( new Error ( 'something wrong' ) ) ) ;
82
- Geocoder . fallbackToGoogle ( 'myGoogleMapsAPIKey' ) ;
83
- return Geocoder . geocodePosition ( position ) . then (
84
- ( ) => { throw new Error ( 'should not be there' ) } ,
85
- ( err ) => { expect ( err . message ) . to . eql ( 'something wrong' ) ; }
86
- ) ;
87
- } ) ;
88
79
} ) ;
89
80
90
81
describe ( 'geocodeAddress' , function ( ) {
@@ -113,19 +104,9 @@ describe('geocoder', function() {
113
104
) ;
114
105
} ) ;
115
106
116
- it ( 'does not fallback to google api on error' , function ( ) {
117
- const address = 'london' ;
118
- RNGeocoder . geocodeAddress = sinon . stub ( ) . returns ( Promise . reject ( new Error ( 'something wrong' ) ) ) ;
119
- Geocoder . fallbackToGoogle ( 'myGoogleMapsAPIKey' ) ;
120
- return Geocoder . geocodeAddress ( address ) . then (
121
- ( ) => { throw new Error ( 'should not be there' ) } ,
122
- ( err ) => { expect ( err . message ) . to . eql ( 'something wrong' ) ; }
123
- ) ;
124
- } ) ;
125
-
126
- it ( 'fallbacks to google api on error' , async function ( ) {
107
+ it ( 'always fallbacks to google api on error' , async function ( ) {
127
108
const address = 'london' ;
128
- RNGeocoder . geocodeAddress = sinon . stub ( ) . returns ( Promise . reject ( { code : 'NOT_AVAILABLE' } ) ) ;
109
+ RNGeocoder . geocodeAddress = sinon . stub ( ) . returns ( Promise . reject ( null ) ) ;
129
110
Geocoder . fallbackToGoogle ( 'myGoogleMapsAPIKey' ) ;
130
111
const ret = await Geocoder . geocodeAddress ( address ) ;
131
112
expect ( GoogleApi . geocodeAddress ) . to . have . been . calledWith ( 'myGoogleMapsAPIKey' , address ) ;
0 commit comments