@masterportal/masterportalapi 2.20.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,103 @@
1
1
  import {Draw} from "ol/interaction.js";
2
+ import Feature from "ol/Feature";
3
+ import Circle from "ol/geom/Circle";
2
4
  import VectorSource from "ol/source/Vector";
3
5
 
4
- import drawInteractions from "../../../src/maps/interactions/drawInteractions";
6
+ import drawInteractions, {styleObject} from "../../../src/maps/interactions/drawInteractions";
5
7
 
6
8
  describe("src/maps/interactions/drawInteractions.js", () => {
9
+ describe("transformMapUnitRadius", () => {
10
+ it("should return the input meter radius in meter ", () => {
11
+ const radius = 100,
12
+ mapProjection = {
13
+ getUnits: () => "m"
14
+ },
15
+ mapUnitRadius = drawInteractions.transformMapUnitRadius(radius, mapProjection);
16
+
17
+ expect(mapUnitRadius).toEqual(100);
18
+ });
19
+
20
+ it("should return the input degree radius in meter ", () => {
21
+ const radius = 100,
22
+ mapProjection = {
23
+ getUnits: () => "degrees"
24
+ },
25
+ mapUnitRadius = drawInteractions.transformMapUnitRadius(radius, mapProjection);
26
+
27
+ expect(mapUnitRadius).toEqual(0.0008983152841195215);
28
+ });
29
+ });
30
+
31
+ describe("drawInnerCircle", () => {
32
+ it("should set radius for circle feature", () => {
33
+ const feature = new Feature({geometry: new Circle([565826.38, 5934174.40], 10)}),
34
+ mapProjection = {
35
+ getUnits: () => "m"
36
+ },
37
+ options = {
38
+ innerRadius: 100,
39
+ interactive: false,
40
+ outerRadius: 500
41
+ };
42
+
43
+ drawInteractions.drawInnerCircle(feature, mapProjection, options);
44
+
45
+ expect(feature.getGeometry().getRadius()).toEqual(100);
46
+ });
47
+ });
48
+
49
+ describe("setStyleObject", () => {
50
+ it("should set style object", () => {
51
+ const currentLayout = {
52
+ fillColor: [55, 126, 184],
53
+ fillTransparency: 0,
54
+ strokeColor: [0, 0, 0],
55
+ strokeWidth: 1
56
+ };
57
+
58
+ drawInteractions.setStyleObject(currentLayout);
59
+
60
+ expect(styleObject).toEqual({
61
+ rules: [
62
+ {
63
+ style: {
64
+ circleFillColor: [
65
+ 55,
66
+ 126,
67
+ 184,
68
+ 1
69
+ ],
70
+ circleStrokeColor: [
71
+ 0,
72
+ 0,
73
+ 0
74
+ ],
75
+ circleStrokeWidth: 1,
76
+ lineStrokeColor: [
77
+ 0,
78
+ 0,
79
+ 0
80
+ ],
81
+ lineStrokeWidth: 1,
82
+ polygonFillColor: [
83
+ 55,
84
+ 126,
85
+ 184,
86
+ 1
87
+ ],
88
+ polygonStrokeColor: [
89
+ 0,
90
+ 0,
91
+ 0
92
+ ],
93
+ polygonStrokeWidth: 1
94
+ }
95
+ }
96
+ ]
97
+ });
98
+ });
99
+ });
100
+
7
101
  describe("createDrawInteraction", () => {
8
102
  it("should create a draw interaction", () => {
9
103
  const source = new VectorSource(),
@@ -26,25 +120,4 @@ describe("src/maps/interactions/drawInteractions.js", () => {
26
120
  });
27
121
  });
28
122
 
29
- describe("transformMapUnitRadius", () => {
30
- it("should return the input meter radius in meter ", () => {
31
- const radius = 100,
32
- mapProjection = {
33
- getUnits: () => "m"
34
- },
35
- mapUnitRadius = drawInteractions.transformMapUnitRadius(radius, mapProjection);
36
-
37
- expect(mapUnitRadius).toEqual(100);
38
- });
39
-
40
- it("should return the input degree radius in meter ", () => {
41
- const radius = 100,
42
- mapProjection = {
43
- getUnits: () => "degrees"
44
- },
45
- mapUnitRadius = drawInteractions.transformMapUnitRadius(radius, mapProjection);
46
-
47
- expect(mapUnitRadius).toEqual(0.0008983152841195215);
48
- });
49
- });
50
123
  });
@@ -0,0 +1,31 @@
1
+ import CircleStyle from "../../../src/vectorStyle/styles/styleCircle";
2
+ import {Style} from "ol/style.js";
3
+
4
+ describe("styleCircle", () => {
5
+ const feature = {
6
+ geometryName: "geom",
7
+ id: "DE.HH.UP_GESUNDHEIT_KRANKENHAEUSER_2"
8
+ },
9
+ style = {
10
+ type: "icon",
11
+ legendValue: "Krankenhaus",
12
+ imageName: "krankenhaus.png"
13
+ },
14
+ isClustered = false,
15
+ styleCircleClass = new CircleStyle(feature, style, isClustered);
16
+
17
+ describe("initialize", function () {
18
+ it("returns an instance of openlayers style", () => {
19
+ expect(typeof styleCircleClass.initialize).toBe("function");
20
+ });
21
+ });
22
+
23
+ describe("createStyle", function () {
24
+ it("returns an instance of openlayers style", () => {
25
+ const createdStyle = styleCircleClass.createStyle();
26
+
27
+ styleCircleClass.setStyle(createdStyle);
28
+ expect(styleCircleClass.getStyle()).toBeInstanceOf(Style);
29
+ });
30
+ });
31
+ });