Skip to content

Commit 40d093b

Browse files
committed
Update test suit
1 parent 54a9dbc commit 40d093b

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

test/unit/geocoder.test.js

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,15 @@ describe('geocoder', function() {
6767
);
6868
});
6969

70-
it ('fallbacks to google api when not available', async function() {
70+
it ('always fallbacks to google api on error', async function() {
7171
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));
7373
Geocoder.fallbackToGoogle('myGoogleMapsAPIKey');
7474
const ret = await Geocoder.geocodePosition(position);
7575
expect(GoogleApi.geocodePosition).to.have.been.calledWith('myGoogleMapsAPIKey', position);
7676
expect(ret).to.eql('google');
7777
});
7878

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-
});
8879
});
8980

9081
describe('geocodeAddress', function() {
@@ -113,19 +104,9 @@ describe('geocoder', function() {
113104
);
114105
});
115106

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() {
127108
const address = 'london';
128-
RNGeocoder.geocodeAddress = sinon.stub().returns(Promise.reject({code: 'NOT_AVAILABLE'}));
109+
RNGeocoder.geocodeAddress = sinon.stub().returns(Promise.reject(null));
129110
Geocoder.fallbackToGoogle('myGoogleMapsAPIKey');
130111
const ret = await Geocoder.geocodeAddress(address);
131112
expect(GoogleApi.geocodeAddress).to.have.been.calledWith('myGoogleMapsAPIKey', address);

0 commit comments

Comments
 (0)