@esri/solutions-components 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/calcite-input-text_5.cjs.entry.js +36 -36
- package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +1 -1
- package/dist/cjs/solution-configuration.cjs.entry.js +1 -1
- package/dist/cjs/solution-contents_3.cjs.entry.js +1 -1
- package/dist/cjs/{solution-store-70002b57.js → solution-store-ca4639d5.js} +3 -3
- package/dist/collection/components/add-record-modal/test/add-record-modal.e2e.js +24 -0
- package/dist/collection/components/add-record-modal/test/add-record-modal.spec.js +32 -0
- package/dist/collection/components/buffer-tools/test/buffer-tools.e2e.js +24 -0
- package/dist/collection/components/buffer-tools/test/buffer-tools.spec.js +157 -0
- package/dist/collection/components/card-manager/test/card-manager.e2e.js +24 -0
- package/dist/collection/components/card-manager/test/card-manager.spec.js +32 -0
- package/dist/collection/components/comment-card/test/comment-card.e2e.js +24 -0
- package/dist/collection/components/comment-card/test/comment-card.spec.js +32 -0
- package/dist/collection/components/crowdsource-manager/test/crowdsource-manager.e2e.js +24 -0
- package/dist/collection/components/crowdsource-manager/test/crowdsource-manager.spec.js +32 -0
- package/dist/collection/components/crowdsource-reporter/test/crowdsource-reporter.e2e.js +24 -0
- package/dist/collection/components/crowdsource-reporter/test/crowdsource-reporter.spec.js +32 -0
- package/dist/collection/components/deduct-calculator/test/deduct-calculator.e2e.js +24 -0
- package/dist/collection/components/deduct-calculator/test/deduct-calculator.spec.js +32 -0
- package/dist/collection/components/edit-record-modal/test/edit-record-modal.e2e.js +24 -0
- package/dist/collection/components/edit-record-modal/test/edit-record-modal.spec.js +32 -0
- package/dist/collection/components/info-card/test/info-card.e2e.js +24 -0
- package/dist/collection/components/info-card/test/info-card.spec.js +32 -0
- package/dist/collection/components/json-editor/test/json-editor.e2e.js +31 -0
- package/dist/collection/components/json-editor/test/json-editor.spec.js +60 -0
- package/dist/collection/components/layer-table/test/layer-table.e2e.js +24 -0
- package/dist/collection/components/layer-table/test/layer-table.spec.js +32 -0
- package/dist/collection/components/list-item/test/list-item.e2e.js +24 -0
- package/dist/collection/components/list-item/test/list-item.spec.js +32 -0
- package/dist/collection/components/map-card/test/map-card.e2e.js +24 -0
- package/dist/collection/components/map-card/test/map-card.spec.js +32 -0
- package/dist/collection/components/map-draw-tools/test/map-draw-tools.e2e.js +24 -0
- package/dist/collection/components/map-draw-tools/test/map-draw-tools.spec.js +32 -0
- package/dist/collection/components/map-layer-picker/test/map-layer-picker.e2e.js +24 -0
- package/dist/collection/components/map-layer-picker/test/map-layer-picker.spec.js +109 -0
- package/dist/collection/components/map-search/test/map-search.e2e.js +24 -0
- package/dist/collection/components/map-search/test/map-search.spec.js +53 -0
- package/dist/collection/components/map-select-tools/map-select-tools.js +36 -36
- package/dist/collection/components/map-select-tools/test/map-select-tools.e2e.js +24 -0
- package/dist/collection/components/map-select-tools/test/map-select-tools.spec.js +349 -0
- package/dist/collection/components/media-card/test/media-card.e2e.js +24 -0
- package/dist/collection/components/media-card/test/media-card.spec.js +32 -0
- package/dist/collection/components/pci-calculator/test/pci-calculator.e2e.js +24 -0
- package/dist/collection/components/pci-calculator/test/pci-calculator.spec.js +32 -0
- package/dist/collection/components/pdf-download/test/pdf-download.e2e.js +71 -0
- package/dist/collection/components/pdf-download/test/pdf-download.spec.js +104 -0
- package/dist/collection/components/public-notification/test/public-notification.e2e.js +95 -0
- package/dist/collection/components/public-notification/test/public-notification.spec.js +149 -0
- package/dist/collection/components/refine-selection/refine-selection.css +85 -85
- package/dist/collection/components/solution-configuration/test/solution-configuration.e2e.js +31 -0
- package/dist/collection/components/solution-configuration/test/solution-configuration.spec.js +114 -0
- package/dist/collection/components/solution-contents/test/solution-contents.e2e.js +89 -0
- package/dist/collection/components/solution-contents/test/solution-contents.spec.js +138 -0
- package/dist/collection/components/solution-item/test/solution-item.e2e.js +31 -0
- package/dist/collection/components/solution-item/test/solution-item.spec.js +72 -0
- package/dist/collection/components/solution-item-details/test/solution-item-details.e2e.js +31 -0
- package/dist/collection/components/solution-item-details/test/solution-item-details.spec.js +137 -0
- package/dist/collection/components/solution-item-icon/test/solution-item-icon.e2e.js +24 -0
- package/dist/collection/components/solution-item-icon/test/solution-item-icon.spec.js +34 -0
- package/dist/collection/components/solution-item-sharing/test/solution-item-sharing.e2e.js +31 -0
- package/dist/collection/components/solution-item-sharing/test/solution-item-sharing.spec.js +49 -0
- package/dist/collection/components/solution-organization-variables/test/solution-organization-variables.e2e.js +31 -0
- package/dist/collection/components/solution-organization-variables/test/solution-organization-variables.spec.js +60 -0
- package/dist/collection/components/solution-resource-item/test/solution-resource-item.e2e.js +31 -0
- package/dist/collection/components/solution-resource-item/test/solution-resource-item.spec.js +50 -0
- package/dist/collection/components/solution-spatial-ref/test/solution-spatial-ref.e2e.js +31 -0
- package/dist/collection/components/solution-spatial-ref/test/solution-spatial-ref.spec.js +170 -0
- package/dist/collection/components/solution-template-data/test/solution-template-data.e2e.js +31 -0
- package/dist/collection/components/solution-template-data/test/solution-template-data.spec.js +55 -0
- package/dist/collection/components/solution-variables/test/solution-variables.e2e.js +31 -0
- package/dist/collection/components/solution-variables/test/solution-variables.spec.js +126 -0
- package/dist/collection/utils/publicNotificationUtils.js +45 -0
- package/dist/collection/utils/templates.e2e.js +25 -0
- package/dist/collection/utils/test/csvUtils.spec.js +46 -0
- package/dist/collection/utils/test/downloadUtils.spec.js +102 -0
- package/dist/collection/utils/test/pciUtils.spec.js +297 -0
- package/dist/collection/utils/test/solution-store.spec.js +439 -0
- package/dist/components/map-select-tools2.js +36 -36
- package/dist/components/solution-store.js +3 -3
- package/dist/esm/calcite-input-text_5.entry.js +36 -36
- package/dist/esm/calcite-shell-panel_14.entry.js +1 -1
- package/dist/esm/solution-configuration.entry.js +1 -1
- package/dist/esm/solution-contents_3.entry.js +1 -1
- package/dist/esm/{solution-store-5d068b07.js → solution-store-70f874f8.js} +3 -3
- package/dist/solutions-components/{p-41802f6b.entry.js → p-16dfb254.entry.js} +1 -1
- package/dist/solutions-components/{p-4769a2a5.entry.js → p-5ed755a2.entry.js} +1 -1
- package/dist/solutions-components/{p-826a814d.js → p-78719506.js} +2 -2
- package/dist/solutions-components/{p-9f620303.entry.js → p-b4b19fd3.entry.js} +1 -1
- package/dist/solutions-components/{p-24fe6e1c.entry.js → p-d5d5942d.entry.js} +1 -1
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/common.js +291 -0
- package/dist/solutions-components/utils/csvDownload.js +36 -0
- package/dist/solutions-components/utils/csvUtils.js +32 -0
- package/dist/solutions-components/utils/downloadUtils.js +386 -0
- package/dist/solutions-components/utils/interfaces.js +56 -0
- package/dist/solutions-components/utils/languageUtil.js +85 -0
- package/dist/solutions-components/utils/loadModules.js +20 -0
- package/dist/solutions-components/utils/locale.js +56 -0
- package/dist/solutions-components/utils/mapViewUtils.js +140 -0
- package/dist/solutions-components/utils/pciUtils.js +837 -0
- package/dist/solutions-components/utils/pdfUtils.js +62 -0
- package/dist/solutions-components/utils/publicNotificationStore.js +38 -0
- package/dist/solutions-components/utils/publicNotificationUtils.js +45 -0
- package/dist/solutions-components/utils/queryUtils.js +148 -0
- package/dist/solutions-components/utils/solution-store.js +579 -0
- package/dist/solutions-components/utils/templates.e2e.js +25 -0
- package/dist/solutions-components/utils/templates.js +341 -0
- package/dist/solutions-components/utils/test/csvUtils.spec.js +46 -0
- package/dist/solutions-components/utils/test/downloadUtils.spec.js +102 -0
- package/dist/solutions-components/utils/test/mocks/jsApi.js +74 -0
- package/dist/solutions-components/utils/test/pciUtils.spec.js +297 -0
- package/dist/solutions-components/utils/test/solution-store.spec.js +439 -0
- package/dist/solutions-components/utils/test/testUtils.js +135 -0
- package/dist/solutions-components/utils/types.js +14 -0
- package/dist/solutions-components_commit.txt +7 -0
- package/package.json +7 -7
@@ -0,0 +1,126 @@
|
|
1
|
+
/** @license
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
import { newSpecPage } from '@stencil/core/testing';
|
17
|
+
import { SolutionVariables } from '../solution-variables';
|
18
|
+
import { value } from '../../../demos/data/solution-variables-data.json';
|
19
|
+
import { h } from '@stencil/core';
|
20
|
+
xdescribe('solution-variables', () => {
|
21
|
+
it('renders', async () => {
|
22
|
+
const page = await newSpecPage({
|
23
|
+
components: [SolutionVariables],
|
24
|
+
template: () => (h("solution-variables", { value: JSON.stringify(value) }))
|
25
|
+
});
|
26
|
+
expect(page.root).toEqualHtml(`
|
27
|
+
<solution-variables>
|
28
|
+
<mock:shadow-root>
|
29
|
+
<div>
|
30
|
+
<h4 class="org-var-header">
|
31
|
+
Solution Variables
|
32
|
+
</h4>
|
33
|
+
</div>
|
34
|
+
<div class="container-border">
|
35
|
+
<calcite-label id="variable-label">
|
36
|
+
<calcite-tree-item>
|
37
|
+
<solution-item-icon></solution-item-icon>
|
38
|
+
<span class="icon-text" title="Dashboard 1">
|
39
|
+
Dashboard 1
|
40
|
+
</span>
|
41
|
+
<calcite-tree slot="children">
|
42
|
+
<calcite-tree-item>
|
43
|
+
Item Id
|
44
|
+
</calcite-tree-item>
|
45
|
+
<calcite-tree-item>
|
46
|
+
Url
|
47
|
+
</calcite-tree-item>
|
48
|
+
</calcite-tree>
|
49
|
+
</calcite-tree-item>
|
50
|
+
<calcite-tree-item>
|
51
|
+
<solution-item-icon></solution-item-icon>
|
52
|
+
<span class="icon-text" title="Dashboard 2">
|
53
|
+
Dashboard 2
|
54
|
+
</span>
|
55
|
+
<calcite-tree slot="children">
|
56
|
+
<calcite-tree-item>
|
57
|
+
Item Id
|
58
|
+
</calcite-tree-item>
|
59
|
+
<calcite-tree-item>
|
60
|
+
Url
|
61
|
+
</calcite-tree-item>
|
62
|
+
</calcite-tree>
|
63
|
+
</calcite-tree-item>
|
64
|
+
<calcite-tree-item>
|
65
|
+
<solution-item-icon></solution-item-icon>
|
66
|
+
<span class="icon-text" title="Feature Service 1">
|
67
|
+
Feature Service 1
|
68
|
+
</span>
|
69
|
+
<calcite-tree slot="children">
|
70
|
+
<calcite-tree-item>
|
71
|
+
Item Id
|
72
|
+
</calcite-tree-item>
|
73
|
+
<calcite-tree-item>
|
74
|
+
Url
|
75
|
+
</calcite-tree-item>
|
76
|
+
<calcite-tree-item>
|
77
|
+
Name
|
78
|
+
</calcite-tree-item>
|
79
|
+
<calcite-tree-item>
|
80
|
+
<solution-item-icon></solution-item-icon>
|
81
|
+
<span class="icon-text" title="Layer 0">
|
82
|
+
Layer 0
|
83
|
+
</span>
|
84
|
+
<calcite-tree slot="children">
|
85
|
+
<calcite-tree-item>
|
86
|
+
Id
|
87
|
+
</calcite-tree-item>
|
88
|
+
<calcite-tree-item>
|
89
|
+
Url
|
90
|
+
</calcite-tree-item>
|
91
|
+
</calcite-tree>
|
92
|
+
</calcite-tree-item>
|
93
|
+
<calcite-tree-item>
|
94
|
+
<solution-item-icon></solution-item-icon>
|
95
|
+
<span class="icon-text" title="Layer 1">
|
96
|
+
Layer 1
|
97
|
+
</span>
|
98
|
+
<calcite-tree slot="children">
|
99
|
+
<calcite-tree-item>
|
100
|
+
Id
|
101
|
+
</calcite-tree-item>
|
102
|
+
<calcite-tree-item>
|
103
|
+
Url
|
104
|
+
</calcite-tree-item>
|
105
|
+
</calcite-tree>
|
106
|
+
</calcite-tree-item>
|
107
|
+
</calcite-tree>
|
108
|
+
</calcite-tree-item>
|
109
|
+
<calcite-tree-item>
|
110
|
+
<solution-item-icon></solution-item-icon>
|
111
|
+
<span class="icon-text" title="Group 1">
|
112
|
+
Group 1
|
113
|
+
</span>
|
114
|
+
<calcite-tree slot="children">
|
115
|
+
<calcite-tree-item>
|
116
|
+
Group Id
|
117
|
+
</calcite-tree-item>
|
118
|
+
</calcite-tree>
|
119
|
+
</calcite-tree-item>
|
120
|
+
</calcite-label>
|
121
|
+
</div>
|
122
|
+
</mock:shadow-root>
|
123
|
+
</solution-variables>
|
124
|
+
`);
|
125
|
+
});
|
126
|
+
});
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/** @license
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
export function getSelectionIds(selectionSets) {
|
17
|
+
return Object.keys(selectionSets).reduce((prev, cur) => {
|
18
|
+
return [
|
19
|
+
...prev,
|
20
|
+
...selectionSets[cur].download ? selectionSets[cur].selectedIds : []
|
21
|
+
];
|
22
|
+
}, []);
|
23
|
+
}
|
24
|
+
export function getSelectionIdsAndViews(selectionSets) {
|
25
|
+
return selectionSets.reduce((prev, cur) => {
|
26
|
+
if (Object.keys(prev).indexOf(cur.layerView.layer.id) > -1) {
|
27
|
+
prev[cur.layerView.layer.id].ids = [
|
28
|
+
...prev[cur.layerView.layer.id].ids,
|
29
|
+
...cur.selectedIds
|
30
|
+
];
|
31
|
+
prev[cur.layerView.layer.id].selectionSetNames.push(cur.label);
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
prev[cur.layerView.layer.id] = {
|
35
|
+
ids: cur.selectedIds,
|
36
|
+
layerView: cur.layerView,
|
37
|
+
selectionSetNames: [cur.label]
|
38
|
+
};
|
39
|
+
}
|
40
|
+
return prev;
|
41
|
+
}, {});
|
42
|
+
}
|
43
|
+
export function getTotal(selectionSets) {
|
44
|
+
return [...new Set(getSelectionIds(selectionSets))].length;
|
45
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/** @license
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
import { getInventoryItems } from "./templates";
|
17
|
+
import * as electionOutreach from '../demos/data/election-outreach.json';
|
18
|
+
describe("getInventoryItems", () => {
|
19
|
+
it("can get inventory items", () => {
|
20
|
+
const templates = electionOutreach.templates;
|
21
|
+
expect(templates.length).toEqual(11);
|
22
|
+
const actual = getInventoryItems(templates);
|
23
|
+
expect(actual.length).toEqual(5);
|
24
|
+
});
|
25
|
+
});
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/** @license
|
2
|
+
* Copyright 2023 Esri
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
import * as csvDownload from "../csvDownload";
|
17
|
+
import * as csvUtils from "../csvUtils";
|
18
|
+
import { expect, jest } from "@jest/globals";
|
19
|
+
afterEach(() => {
|
20
|
+
jest.restoreAllMocks();
|
21
|
+
});
|
22
|
+
describe("csvUtils", () => {
|
23
|
+
describe("exportCSV", () => {
|
24
|
+
it("prepares output lines 1", () => {
|
25
|
+
const title = "title";
|
26
|
+
const labels = [
|
27
|
+
["Cyd Charise", "1922 Main St", "Amarillo, TX 79118"],
|
28
|
+
["Fred Astaire", "1899 Main St", "Omaha, NE 68022"],
|
29
|
+
["Gene Kelly", "1912 Main St", "Pittsburgh, PA 15215"],
|
30
|
+
["Ginger Rogers", "1911 Main St", "Independence, MO 64050"]
|
31
|
+
];
|
32
|
+
const expectedOutputLines = [
|
33
|
+
"\"Cyd Charise\",\"1922 Main St\",\"Amarillo, TX 79118\"\r\n",
|
34
|
+
"\"Fred Astaire\",\"1899 Main St\",\"Omaha, NE 68022\"\r\n",
|
35
|
+
"\"Gene Kelly\",\"1912 Main St\",\"Pittsburgh, PA 15215\"\r\n",
|
36
|
+
"\"Ginger Rogers\",\"1911 Main St\",\"Independence, MO 64050\"\r\n"
|
37
|
+
];
|
38
|
+
const downloadCSVFileMock = jest.spyOn(csvDownload, "downloadCSVFile")
|
39
|
+
.mockImplementation((fileTitle, outputLines) => { });
|
40
|
+
csvUtils.exportCSV(title, labels);
|
41
|
+
expect(downloadCSVFileMock).toBeCalledTimes(1);
|
42
|
+
expect(downloadCSVFileMock.mock.calls[0][0]).toEqual(title);
|
43
|
+
expect(downloadCSVFileMock.mock.calls[0][1]).toEqual(expectedOutputLines);
|
44
|
+
});
|
45
|
+
});
|
46
|
+
});
|
@@ -0,0 +1,102 @@
|
|
1
|
+
/** @license
|
2
|
+
* Copyright 2023 Esri
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
import * as downloadUtils from "../downloadUtils";
|
17
|
+
describe("downloadUtils", () => {
|
18
|
+
describe("_convertPopupFieldsToLabelSpec", () => {
|
19
|
+
it("handles fieldname visibility", () => {
|
20
|
+
const fieldInfos = [
|
21
|
+
{ fieldName: "A", visible: true },
|
22
|
+
{ fieldName: "B", visible: true },
|
23
|
+
{ fieldName: "C", visible: false },
|
24
|
+
{ fieldName: "D", visible: true }
|
25
|
+
];
|
26
|
+
const bypassFieldVisiblity = false;
|
27
|
+
const expectedLabelSpec = "{A}|{B}|{D}";
|
28
|
+
const labelSpec = downloadUtils._convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity);
|
29
|
+
expect(labelSpec).toEqual(expectedLabelSpec);
|
30
|
+
});
|
31
|
+
it("handles fieldname ignoring visibility", () => {
|
32
|
+
const fieldInfos = [
|
33
|
+
{ fieldName: "A", visible: true },
|
34
|
+
{ fieldName: "B", visible: true },
|
35
|
+
{ fieldName: "C", visible: false },
|
36
|
+
{ fieldName: "D", visible: true }
|
37
|
+
];
|
38
|
+
const bypassFieldVisiblity = true;
|
39
|
+
const expectedLabelSpec = "{A}|{B}|{C}|{D}";
|
40
|
+
const labelSpec = downloadUtils._convertPopupFieldsToLabelSpec(fieldInfos, bypassFieldVisiblity);
|
41
|
+
expect(labelSpec).toEqual(expectedLabelSpec);
|
42
|
+
});
|
43
|
+
});
|
44
|
+
describe("_convertPopupTextToLabelSpec", () => {
|
45
|
+
it("handles <br> variants", () => {
|
46
|
+
const popupInfo = "<div style='text-align: left;'>{NAME}<br />{STREET}<br/>{CITY}, {STATE} {ZIP} <br></div>";
|
47
|
+
const expectedLabelSpec = "{NAME}|{STREET}|{CITY}, {STATE} {ZIP}";
|
48
|
+
const labelSpec = downloadUtils._convertPopupTextToLabelSpec(popupInfo);
|
49
|
+
expect(labelSpec).toEqual(expectedLabelSpec);
|
50
|
+
});
|
51
|
+
it("handles <p>", () => {
|
52
|
+
const popupInfo = "<p>{NAME}</p><p>{STREET}</p><p>{CITY}, {STATE} {ZIP}</p>";
|
53
|
+
const expectedLabelSpec = "{NAME}|{STREET}|{CITY}, {STATE} {ZIP}";
|
54
|
+
const labelSpec = downloadUtils._convertPopupTextToLabelSpec(popupInfo);
|
55
|
+
expect(labelSpec).toEqual(expectedLabelSpec);
|
56
|
+
});
|
57
|
+
it("handles popup's use of \xA0", () => {
|
58
|
+
const popupInfo = "<div style='text-align: left;'>{NAME}<br />{STREET}<br />{CITY},\xA0{STATE}\xA0{ZIP}\xA0<br /></div>";
|
59
|
+
const expectedLabelSpec = "{NAME}|{STREET}|{CITY}, {STATE} {ZIP}";
|
60
|
+
const labelSpec = downloadUtils._convertPopupTextToLabelSpec(popupInfo);
|
61
|
+
expect(labelSpec).toEqual(expectedLabelSpec);
|
62
|
+
});
|
63
|
+
it("removes newlines and blank lines, and trims each line", () => {
|
64
|
+
const popupInfo = " \n\n {NAME} \n \n\n {STREET}\n{CITY}, {STATE} {ZIP}\n\n \n ";
|
65
|
+
const expectedLabelSpec = "{NAME}|{STREET}|{CITY}, {STATE} {ZIP}";
|
66
|
+
const labelSpec = downloadUtils._convertPopupTextToLabelSpec(popupInfo);
|
67
|
+
expect(labelSpec).toEqual(expectedLabelSpec);
|
68
|
+
});
|
69
|
+
it("removes extra HTML", () => {
|
70
|
+
const popupInfo = "\n<div style='text-align: left;'><span style='font-weight:bold'>{NAME}</span><br />{STREET}<br />{CITY},\xA0{STATE}\xA0{ZIP}\xA0<br /></div>\n";
|
71
|
+
const expectedLabelSpec = "{NAME}|{STREET}|{CITY}, {STATE} {ZIP}";
|
72
|
+
const labelSpec = downloadUtils._convertPopupTextToLabelSpec(popupInfo);
|
73
|
+
expect(labelSpec).toEqual(expectedLabelSpec);
|
74
|
+
});
|
75
|
+
it("handles some special characters", () => {
|
76
|
+
const popupInfo = "<div style='text-align: left;'><{NAME}><br />{STREET}<br/>{CITY}, {STATE} {ZIP}<br></div>";
|
77
|
+
const expectedLabelSpec = "<{NAME}>|{STREET}|{CITY}, {STATE} {ZIP}";
|
78
|
+
const labelSpec = downloadUtils._convertPopupTextToLabelSpec(popupInfo);
|
79
|
+
expect(labelSpec).toEqual(expectedLabelSpec);
|
80
|
+
});
|
81
|
+
});
|
82
|
+
describe("_createTitle", () => {
|
83
|
+
it("handles no selection set names", () => {
|
84
|
+
const selectionSetNames = [];
|
85
|
+
const expectedTitle = "download";
|
86
|
+
const title = downloadUtils._createTitle(selectionSetNames);
|
87
|
+
expect(title).toEqual(expectedTitle);
|
88
|
+
});
|
89
|
+
it("handles one selection set name", () => {
|
90
|
+
const selectionSetNames = ["fred"];
|
91
|
+
const expectedTitle = "fred";
|
92
|
+
const title = downloadUtils._createTitle(selectionSetNames);
|
93
|
+
expect(title).toEqual(expectedTitle);
|
94
|
+
});
|
95
|
+
it("handles two selection set names", () => {
|
96
|
+
const selectionSetNames = ["fred", "ginger"];
|
97
|
+
const expectedTitle = "fred,ginger";
|
98
|
+
const title = downloadUtils._createTitle(selectionSetNames);
|
99
|
+
expect(title).toEqual(expectedTitle);
|
100
|
+
});
|
101
|
+
});
|
102
|
+
});
|
@@ -0,0 +1,297 @@
|
|
1
|
+
/** @license
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
import * as pciUtils from "../pciUtils";
|
17
|
+
jest.setTimeout(30000);
|
18
|
+
afterEach(() => {
|
19
|
+
jest.restoreAllMocks();
|
20
|
+
});
|
21
|
+
describe("pciUtils", () => {
|
22
|
+
it("calculateDeductValue", () => {
|
23
|
+
const logMock = jest.spyOn(console, "log").mockImplementation(() => { });
|
24
|
+
// 1
|
25
|
+
let type = "1";
|
26
|
+
let actual = pciUtils.calculateDeductValue(type, "L", "0.52", true);
|
27
|
+
let expected = "1|L|7.4|0.52";
|
28
|
+
expect(actual).toEqual(expected);
|
29
|
+
expect(logMock).toBeCalledTimes(3);
|
30
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
31
|
+
expected = "1|M|16|0.52";
|
32
|
+
expect(actual).toEqual(expected);
|
33
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
34
|
+
expected = "1|H|23.3|0.52";
|
35
|
+
expect(actual).toEqual(expected);
|
36
|
+
// 2
|
37
|
+
type = "2";
|
38
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
39
|
+
expected = "2|L|0|0.52";
|
40
|
+
expect(actual).toEqual(expected);
|
41
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
42
|
+
expected = "2|M|1.1|0.52";
|
43
|
+
expect(actual).toEqual(expected);
|
44
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
45
|
+
expected = "2|H|3.9|0.52";
|
46
|
+
expect(actual).toEqual(expected);
|
47
|
+
// 3
|
48
|
+
type = "3";
|
49
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
50
|
+
expected = "3|L|-0.2|0.52";
|
51
|
+
expect(actual).toEqual(expected);
|
52
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
53
|
+
expected = "3|M|0.5|0.52";
|
54
|
+
expect(actual).toEqual(expected);
|
55
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
56
|
+
expected = "3|H|5.2|0.52";
|
57
|
+
expect(actual).toEqual(expected);
|
58
|
+
// 4
|
59
|
+
type = "4";
|
60
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
61
|
+
expected = "4|L|5.3|0.52";
|
62
|
+
expect(actual).toEqual(expected);
|
63
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
64
|
+
expected = "4|M|17.9|0.52";
|
65
|
+
expect(actual).toEqual(expected);
|
66
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
67
|
+
expected = "4|H|42.7|0.52";
|
68
|
+
expect(actual).toEqual(expected);
|
69
|
+
// 5
|
70
|
+
type = "5";
|
71
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
72
|
+
expected = "5|L|1.1|0.52";
|
73
|
+
expect(actual).toEqual(expected);
|
74
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
75
|
+
expected = "5|M|10.7|0.52";
|
76
|
+
expect(actual).toEqual(expected);
|
77
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
78
|
+
expected = "5|H|28.1|0.52";
|
79
|
+
expect(actual).toEqual(expected);
|
80
|
+
// 6
|
81
|
+
type = "6";
|
82
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
83
|
+
expected = "6|L|5.2|0.52";
|
84
|
+
expect(actual).toEqual(expected);
|
85
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
86
|
+
expected = "6|M|8.1|0.52";
|
87
|
+
expect(actual).toEqual(expected);
|
88
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
89
|
+
expected = "6|H|16.5|0.52";
|
90
|
+
expect(actual).toEqual(expected);
|
91
|
+
// 7
|
92
|
+
type = "7";
|
93
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
94
|
+
expected = "7|L|2|0.52";
|
95
|
+
expect(actual).toEqual(expected);
|
96
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
97
|
+
expected = "7|M|6.7|0.52";
|
98
|
+
expect(actual).toEqual(expected);
|
99
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
100
|
+
expected = "7|H|11.9|0.52";
|
101
|
+
expect(actual).toEqual(expected);
|
102
|
+
// 8
|
103
|
+
type = "8";
|
104
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
105
|
+
expected = "8|L|0.8|0.52";
|
106
|
+
expect(actual).toEqual(expected);
|
107
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
108
|
+
expected = "8|M|7.1|0.52";
|
109
|
+
expect(actual).toEqual(expected);
|
110
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
111
|
+
expected = "8|H|11.5|0.52";
|
112
|
+
expect(actual).toEqual(expected);
|
113
|
+
// 9
|
114
|
+
type = "9";
|
115
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
116
|
+
expected = "9|L|2|0.52";
|
117
|
+
expect(actual).toEqual(expected);
|
118
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
119
|
+
expected = "9|M|4|0.52";
|
120
|
+
expect(actual).toEqual(expected);
|
121
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
122
|
+
expected = "9|H|6|0.52";
|
123
|
+
expect(actual).toEqual(expected);
|
124
|
+
// 10
|
125
|
+
type = "10";
|
126
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
127
|
+
expected = "10|L|0.5|0.52";
|
128
|
+
expect(actual).toEqual(expected);
|
129
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
130
|
+
expected = "10|M|5.7|0.52";
|
131
|
+
expect(actual).toEqual(expected);
|
132
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
133
|
+
expected = "10|H|13.5|0.52";
|
134
|
+
expect(actual).toEqual(expected);
|
135
|
+
// 11
|
136
|
+
type = "11";
|
137
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
138
|
+
expected = "11|L|1|0.52";
|
139
|
+
expect(actual).toEqual(expected);
|
140
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
141
|
+
expected = "11|M|7.1|0.52";
|
142
|
+
expect(actual).toEqual(expected);
|
143
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
144
|
+
expected = "11|H|15.7|0.52";
|
145
|
+
expect(actual).toEqual(expected);
|
146
|
+
// 12
|
147
|
+
type = "12";
|
148
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
149
|
+
expected = "12|L|18.8|0.52";
|
150
|
+
expect(actual).toEqual(expected);
|
151
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
152
|
+
expected = "12|M|18.8|0.52";
|
153
|
+
expect(actual).toEqual(expected);
|
154
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
155
|
+
expected = "12|H|18.8|0.52";
|
156
|
+
expect(actual).toEqual(expected);
|
157
|
+
// 13
|
158
|
+
type = "13";
|
159
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
160
|
+
expected = "13|L|46.9|0.52";
|
161
|
+
expect(actual).toEqual(expected);
|
162
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
163
|
+
expected = "13|M|73.4|0.52";
|
164
|
+
expect(actual).toEqual(expected);
|
165
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
166
|
+
expected = "13|H|93.7|0.52";
|
167
|
+
expect(actual).toEqual(expected);
|
168
|
+
// 14
|
169
|
+
type = "14";
|
170
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
171
|
+
expected = "14|L|3.3|0.52";
|
172
|
+
expect(actual).toEqual(expected);
|
173
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
174
|
+
expected = "14|M|-8.7|0.52";
|
175
|
+
expect(actual).toEqual(expected);
|
176
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
177
|
+
expected = "14|H|-1.6|0.52";
|
178
|
+
expect(actual).toEqual(expected);
|
179
|
+
// 15
|
180
|
+
type = "15";
|
181
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
182
|
+
expected = "15|L|4.9|0.52";
|
183
|
+
expect(actual).toEqual(expected);
|
184
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
185
|
+
expected = "15|M|13.1|0.52";
|
186
|
+
expect(actual).toEqual(expected);
|
187
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
188
|
+
expected = "15|H|21.1|0.52";
|
189
|
+
expect(actual).toEqual(expected);
|
190
|
+
// 16
|
191
|
+
type = "16";
|
192
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
193
|
+
expected = "16|L|1.5|0.52";
|
194
|
+
expect(actual).toEqual(expected);
|
195
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
196
|
+
expected = "16|M|6.6|0.52";
|
197
|
+
expect(actual).toEqual(expected);
|
198
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
199
|
+
expected = "16|H|13.7|0.52";
|
200
|
+
expect(actual).toEqual(expected);
|
201
|
+
// 17
|
202
|
+
type = "17";
|
203
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
204
|
+
expected = "17|L|2.4|0.52";
|
205
|
+
expect(actual).toEqual(expected);
|
206
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
207
|
+
expected = "17|M|7.5|0.52";
|
208
|
+
expect(actual).toEqual(expected);
|
209
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
210
|
+
expected = "17|H|12.7|0.52";
|
211
|
+
expect(actual).toEqual(expected);
|
212
|
+
// 18
|
213
|
+
type = "18";
|
214
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
215
|
+
expected = "18|L|-2.8|0.52";
|
216
|
+
expect(actual).toEqual(expected);
|
217
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
218
|
+
expected = "18|M|10|0.52";
|
219
|
+
expect(actual).toEqual(expected);
|
220
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
221
|
+
expected = "18|H|26.3|0.52";
|
222
|
+
expect(actual).toEqual(expected);
|
223
|
+
// 19
|
224
|
+
type = "19";
|
225
|
+
actual = pciUtils.calculateDeductValue(type, "L", "0.52");
|
226
|
+
expected = "19|L|0|0.52";
|
227
|
+
expect(actual).toEqual(expected);
|
228
|
+
actual = pciUtils.calculateDeductValue(type, "M", "0.52");
|
229
|
+
expected = "19|M|7.1|0.52";
|
230
|
+
expect(actual).toEqual(expected);
|
231
|
+
actual = pciUtils.calculateDeductValue(type, "H", "0.52");
|
232
|
+
expected = "19|H|13.9|0.52";
|
233
|
+
expect(actual).toEqual(expected);
|
234
|
+
});
|
235
|
+
it("calculatePCI", () => {
|
236
|
+
const debugMessages = [
|
237
|
+
"Deduct values sorted in descending order: 25.1,23.4,17.9,11.2,7.9,7.5,6.9,5.3",
|
238
|
+
"Highest deduct value: 25.1",
|
239
|
+
"Allowable number of deducts including fractions: 7.87857142857143",
|
240
|
+
"Reduce deduct values to the m largest including the fractional part: 25.1,23.4,17.9,11.2,7.9,7.5,6.9,4.7",
|
241
|
+
"vals: 25.1,23.4,17.9,11.2,7.9,7.5,6.9,4.7",
|
242
|
+
"totalDV: 104.60000000000002",
|
243
|
+
"q: 8",
|
244
|
+
"CDV: 51.412097117472015",
|
245
|
+
"vals: 25.1,23.4,17.9,11.2,7.9,7.5,6.9,2",
|
246
|
+
"totalDV: 101.90000000000002",
|
247
|
+
"q: 7",
|
248
|
+
"CDV: 50.051756691168016",
|
249
|
+
"vals: 25.1,23.4,17.9,11.2,7.9,7.5,2,2",
|
250
|
+
"totalDV: 97.00000000000001",
|
251
|
+
"q: 6",
|
252
|
+
"CDV: 47.48916845800001",
|
253
|
+
"vals: 25.1,23.4,17.9,11.2,7.9,2,2,2",
|
254
|
+
"totalDV: 91.50000000000001",
|
255
|
+
"q: 5",
|
256
|
+
"CDV: 47.433547768125",
|
257
|
+
"vals: 25.1,23.4,17.9,11.2,2,2,2,2",
|
258
|
+
"totalDV: 85.60000000000001",
|
259
|
+
"q: 4",
|
260
|
+
"CDV: 48.57397038028801",
|
261
|
+
"vals: 25.1,23.4,17.9,2,2,2,2,2",
|
262
|
+
"totalDV: 76.4",
|
263
|
+
"q: 3",
|
264
|
+
"CDV: 48.755270187200004",
|
265
|
+
"vals: 25.1,23.4,2,2,2,2,2,2",
|
266
|
+
"totalDV: 60.5",
|
267
|
+
"q: 2",
|
268
|
+
"CDV: 44.42615179325001",
|
269
|
+
"vals: 25.1,2,2,2,2,2,2,2",
|
270
|
+
"totalDV: 39.1",
|
271
|
+
"q: 1",
|
272
|
+
"CDV: 39.1",
|
273
|
+
"Max CDV: 51.412097117472015"
|
274
|
+
];
|
275
|
+
const logMock = jest.spyOn(console, "log").mockImplementation(() => { });
|
276
|
+
const expected = 48.6;
|
277
|
+
const actual = pciUtils.calculatePCI("7.9,23.4,7.5,25.1,17.9,11.2,6.9,5.3", true);
|
278
|
+
expect(actual).toEqual(expected);
|
279
|
+
debugMessages.forEach((m, i) => {
|
280
|
+
expect(logMock).nthCalledWith(i + 1, m);
|
281
|
+
});
|
282
|
+
});
|
283
|
+
it("calculatePCI", () => {
|
284
|
+
const logMock = jest.spyOn(console, "log").mockImplementation(() => { });
|
285
|
+
const expected = 48.6;
|
286
|
+
const actual = pciUtils.calculatePCI("7.9,23.4,7.5,25.1,17.9,11.2,6.9,5.3", false);
|
287
|
+
expect(actual).toEqual(expected);
|
288
|
+
expect(logMock).toBeCalledTimes(0);
|
289
|
+
});
|
290
|
+
it("calculatePCI", () => {
|
291
|
+
const logMock = jest.spyOn(console, "log").mockImplementation(() => { });
|
292
|
+
const expected = 92.1;
|
293
|
+
const actual = pciUtils.calculatePCI("7.9", true);
|
294
|
+
expect(actual).toEqual(expected);
|
295
|
+
expect(logMock).lastCalledWith("Max CDV: 7.9");
|
296
|
+
});
|
297
|
+
});
|