Skip to content

Commit 9d999b9

Browse files
authored
1 parent 23e16c2 commit 9d999b9

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

web/client/utils/WMSUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const getLayerOptions = function(capabilities) {
7272
return isObject(capabilities)
7373
? {
7474
capabilities,
75-
description: capabilities.Abstract,
75+
...(capabilities.Abstract && capabilities.Abstract !== '' && { description: capabilities.Abstract }),
7676
boundingBox: capabilities?.EX_GeographicBoundingBox
7777
? {
7878
minx: capabilities.EX_GeographicBoundingBox?.westBoundLongitude,

web/client/utils/__tests__/WMSUtils-test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,33 @@ describe('Test the WMSUtils', () => {
4343
availableStyles: [{ name: 'generic' }]
4444
});
4545
});
46+
it('test getLayerOptions with empty or no Abstract', () => {
47+
expect(getLayerOptions()).toEqual({});
48+
const capabilities = {
49+
Style: { Name: 'generic' },
50+
LatLonBoundingBox: {$: { minx: -180, miny: -90, maxx: 180, maxy: 90 }}
51+
};
52+
53+
const capabilities2 = {
54+
Style: { Name: 'generic' },
55+
Abstract: '',
56+
LatLonBoundingBox: {$: { minx: -180, miny: -90, maxx: 180, maxy: 90 }}
57+
};
58+
// should not contain description if Abstract is undefined
59+
expect(getLayerOptions(capabilities))
60+
.toEqual({
61+
capabilities,
62+
boundingBox: { minx: -180, miny: -90, maxx: 180, maxy: 90 },
63+
availableStyles: [{ name: 'generic' }]
64+
});
65+
// should not contain description if Abstract is empty string
66+
expect(getLayerOptions(capabilities2))
67+
.toEqual({
68+
capabilities: capabilities2,
69+
boundingBox: { minx: -180, miny: -90, maxx: 180, maxy: 90 },
70+
availableStyles: [{ name: 'generic' }]
71+
});
72+
});
4673
it('test getTileGridFromLayerOptions', () => {
4774
const tileGrids = [
4875
{

0 commit comments

Comments
 (0)