I have some problem with understanding promises. Could you help me please:
I'm trying to use node-geocoder library.
So, this is a function, which should return an array of latitude and longitude of some point on the Google map.
import NodeGeocoder from 'node-geocoder'
export default function getLocation () {
const geocoder = NodeGeocoder({
provider: 'google',
})
const point = geocoder.geocode('29 champs elysée paris', (error, response) => {
return [response[0].latitude, response[0].longitude]
})
return point
}
Previous code should be ok for this test:
import getLocation from './index'
test('This is a test', () => {
expect(getLocation()).toEqual([48.8698679, 2.3072976])
})
Test is failing and I'm receiving the following error message:
Expected value to equal:
[48.8698679, 2.3072976]
Received:
{"fulfillmentValue": undefined, "isFulfilled": false, "isRejected": false, "rejectionReason": undefined}