Skip to content

Commit 2c1850c

Browse files
committed
Add shouldUseLowResolutionCollection tests
1 parent ab80fb5 commit 2c1850c

File tree

1 file changed

+102
-1
lines changed

1 file changed

+102
-1
lines changed

src/layer/__tests__/BYOCLayer.ts

+102-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BBox, CRS_EPSG4326, setAuthToken, LocationIdSHv3, BYOCLayer } from '../../index';
1+
import { CRS_EPSG4326, setAuthToken, LocationIdSHv3, BYOCLayer, CRS_EPSG3857, BBox } from '../../index';
22
import { SHV3_LOCATIONS_ROOT_URL, BYOCSubTypes, SH_SERVICE_ROOT_URL } from '../const';
33
import { constructFixtureFindTilesSearchIndex, constructFixtureFindTilesCatalog } from './fixtures.BYOCLayer';
44

@@ -287,3 +287,104 @@ describe.only('shServiceRootUrl', () => {
287287
expect(layer.getSHServiceRootUrl()).toBe(expected);
288288
});
289289
});
290+
291+
describe.only('shServiceRootUrl', () => {
292+
beforeEach(async () => {
293+
setAuthToken(AUTH_TOKEN);
294+
mockNetwork.reset();
295+
});
296+
297+
test.each([
298+
{
299+
layerParams: {
300+
instanceId: 'INSTANCE_ID',
301+
layerId: 'LAYER_ID',
302+
collectionId: 'mockCollectionId',
303+
subType: BYOCSubTypes.BYOC,
304+
},
305+
lowResolutionCollectionId: 'LOW_RESOLUTION_COLLECTION_ID',
306+
lowResolutionMetersPerPixelThreshold: 300,
307+
bbox: new BBox(
308+
CRS_EPSG4326,
309+
-114.27429199218751,
310+
45.85176048817254,
311+
-112.17864990234376,
312+
48.21003212234042,
313+
),
314+
width: 512,
315+
expected: true,
316+
},
317+
{
318+
layerParams: {
319+
instanceId: 'INSTANCE_ID',
320+
layerId: 'LAYER_ID',
321+
collectionId: 'mockCollectionId',
322+
subType: BYOCSubTypes.BYOC,
323+
},
324+
lowResolutionCollectionId: 'LOW_RESOLUTION_COLLECTION_ID',
325+
lowResolutionMetersPerPixelThreshold: 300,
326+
bbox: new BBox(
327+
CRS_EPSG3857,
328+
-12601714.2312073,
329+
5870363.772301538,
330+
-12523442.714243278,
331+
5948635.289265559,
332+
),
333+
width: 512,
334+
expected: false,
335+
},
336+
{
337+
layerParams: {
338+
instanceId: 'INSTANCE_ID',
339+
layerId: 'LAYER_ID',
340+
collectionId: 'mockCollectionId',
341+
subType: BYOCSubTypes.BYOC,
342+
},
343+
lowResolutionCollectionId: 'LOW_RESOLUTION_COLLECTION_ID',
344+
lowResolutionMetersPerPixelThreshold: 300,
345+
bbox: new BBox(
346+
CRS_EPSG3857,
347+
-15028131.257091936,
348+
2504688.542848655,
349+
-12523442.714243278,
350+
5009377.085697314,
351+
),
352+
width: 512,
353+
expected: true,
354+
},
355+
{
356+
layerParams: {
357+
instanceId: 'INSTANCE_ID',
358+
layerId: 'LAYER_ID',
359+
collectionId: 'mockCollectionId',
360+
subType: BYOCSubTypes.BYOC,
361+
},
362+
lowResolutionCollectionId: 'LOW_RESOLUTION_COLLECTION_ID',
363+
lowResolutionMetersPerPixelThreshold: 300,
364+
bbox: new BBox(
365+
CRS_EPSG3857,
366+
112.81332057952881,
367+
63.97041521013803,
368+
119.85694837570192,
369+
65.98227733565385,
370+
),
371+
width: 512,
372+
expected: false,
373+
},
374+
])(
375+
'shouldUseLowResolutionCollection %p',
376+
async ({
377+
layerParams,
378+
lowResolutionCollectionId,
379+
lowResolutionMetersPerPixelThreshold,
380+
bbox,
381+
width,
382+
expected,
383+
}) => {
384+
const layer = new BYOCLayer(layerParams);
385+
layer.lowResolutionCollectionId = lowResolutionCollectionId;
386+
layer.lowResolutionMetersPerPixelThreshold = lowResolutionMetersPerPixelThreshold;
387+
expect(layer.shouldUseLowResolutionCollection(bbox, width)).toBe(expected);
388+
},
389+
);
390+
});

0 commit comments

Comments
 (0)