|
1 | 1 | // NOTE: this is auto-mocked in __mocks__ |
2 | 2 | import { queryFeatures, decodeValues } from '@esri/arcgis-rest-feature-layer' |
3 | 3 | import {} from 'jest' |
| 4 | +import { IDataset } from '../../src/common' |
4 | 5 | import config from '../../src/config' |
5 | 6 | import { queryDatasets } from '../../src/query/query' |
6 | 7 | import { createQueryParams } from '../../src/query/url' |
@@ -88,6 +89,33 @@ describe('when querying datasets', () => { |
88 | 89 | }) |
89 | 90 | }) |
90 | 91 | }) |
| 92 | + describe('when that dataset has requestOptions', () => { |
| 93 | + const datasets = definitions.bar.datasets |
| 94 | + it('should merge them into those passed to queryFeatures', () => { |
| 95 | + const httpMethod = 'POST' |
| 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 | + } |
| 106 | + } |
| 107 | + return queryDatasets([ dataset ]).then((datasetsData) => { |
| 108 | + // verify that it called queryFeatures once w/ the right parameters |
| 109 | + expect(mockQueryFeatures.mock.calls.length).toEqual(1) |
| 110 | + const requestOptions = mockQueryFeatures.mock.calls[0][0] |
| 111 | + verifyRequestOptions(dataset, requestOptions) |
| 112 | + expect(requestOptions.httpMethod).toEqual(httpMethod) |
| 113 | + expect(datasetsData).toEqual({ |
| 114 | + Number_of_SUM: mockQueryResponse |
| 115 | + }) |
| 116 | + }) |
| 117 | + }) |
| 118 | + }) |
91 | 119 | }) |
92 | 120 | describe('when multiple datasets', () => { |
93 | 121 | beforeEach(() => { |
|
0 commit comments