import axios from 'axios' ; import MockAdapter from 'axios-mock-adapter' ; import type { AxiosInstance } from 'axios' ; import { ProviderAggregator } from '../../../src/geocoder' ; import { NullLogger } from '../../../src/logger' ; import { AccuracyEnum } from '../../../src/model' ; import { ArcgisGeocodeCommand , ArcgisProvider , ArcgisReverseCommand , ArcgisSuggestCommand } from '../../../src/provider' ; import { geocodeQueryFixture , reverseQueryFixture , suggestQueryFixture } from '../../fixture/model/query.fixture' ; import { providerParsedGeocodeResponse , providerParsedReverseResponse , providerParsedSuggestResponse , providerRawGeocodeResponse , providerRawReverseResponse , providerRawSuggestResponse , } from '../../fixture/provider/arcgis.fixture' ; import { sharedAccuracyBehaviours , sharedCommandBehaviours , sharedProvidableBehaviours } from '../common/shared' ; import type { QueryInterface } from '../../../src/interface' ; describe ( 'ProviderAggregator (2e2)' , ( ) => { const client = axios . create ( ) ; const mock = new MockAdapter ( client ) ; const geocoder = new ProviderAggregator ( [ new ArcgisProvider ( client ) ] ) ; geocoder . setLogger ( new NullLogger ( ) ) ; afterEach ( ( ) => { mock . reset ( ) ; } ) ; function sharedBehaviours ( url , method , query , rawResponse , parsedResponse ) { query = { ... query } ; sharedCommandBehaviours ( mock , geocoder , url , method , query , rawResponse , parsedResponse ) ; sharedAccuracyBehaviours ( mock , geocoder , url , method , query , rawResponse , AccuracyEnum . HOUSE_NUMBER ) ; } sharedProvidableBehaviours ( ProviderAggregator as any ) ; describe ( '#geocode' , ( ) => { const url = ArcgisGeocodeCommand . getUrl ( ) ; sharedBehaviours ( url , 'geocode' , geocodeQueryFixture , providerRawGeocodeResponse , providerParsedGeocodeResponse ) ; } ) ; describe ( '#reverse' , ( ) => { const url = ArcgisReverseCommand . getUrl ( ) ; sharedBehaviours ( url , 'reverse' , reverseQueryFixture , providerRawReverseResponse , providerParsedReverseResponse ) ; } ) ; describe ( '#suggest' , ( ) => { const url = ArcgisSuggestCommand . getUrl ( ) ; sharedBehaviours ( url , 'suggest' , suggestQueryFixture , providerRawSuggestResponse , providerParsedSuggestResponse ) ; } ) ; } ) ;