File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed
Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,15 @@ export function queryDatasets(datasets: IDataset[]) {
1717 datasets . forEach ( ( dataset , i ) => {
1818 // only query datasets that don't have inline data
1919 if ( dataset . url ) {
20+ const { url, name, query, requestOptions } = dataset
2021 // TODO: make name required on datasets, or required if > 1 dataset?
21- names . push ( dataset . name || `dataset${ i } ` )
22+ names . push ( name || `dataset${ i } ` )
2223
23- const queryParams = createQueryParams ( dataset . query )
24+ const params = { ... ( requestOptions && requestOptions . params ) , ... createQueryParams ( query ) }
2425 const options : IQueryFeaturesOptions = {
25- ...dataset . requestOptions ,
26- url : dataset . url ,
27- params : queryParams ,
26+ ...requestOptions ,
27+ url,
28+ params,
2829 }
2930 if ( config . fetch && typeof config . fetch === 'function' ) {
3031 // we are configured to use a custom fetch implementation
Original file line number Diff line number Diff line change @@ -93,11 +93,18 @@ describe('when querying datasets', () => {
9393 const datasets = definitions . bar . datasets
9494 it ( 'should merge them into those passed to queryFeatures' , ( ) => {
9595 const httpMethod = 'POST'
96- const dataset : IDataset = datasets [ 0 ]
97- dataset . requestOptions = {
98- httpMethod
96+ const dataset : IDataset = {
97+ ...datasets [ 0 ] ,
98+ requestOptions : {
99+ // override default HTTP method
100+ httpMethod,
101+ params : {
102+ // invalid param should NOT be used
103+ f : 'html'
104+ }
105+ }
99106 }
100- return queryDatasets ( datasets ) . then ( ( datasetsData ) => {
107+ return queryDatasets ( [ dataset ] ) . then ( ( datasetsData ) => {
101108 // verify that it called queryFeatures once w/ the right parameters
102109 expect ( mockQueryFeatures . mock . calls . length ) . toEqual ( 1 )
103110 const requestOptions = mockQueryFeatures . mock . calls [ 0 ] [ 0 ]
You can’t perform that action at this time.
0 commit comments