@datarailsshared/dr_renderer 1.1.41 → 1.2.2

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.
@@ -0,0 +1,365 @@
1
+ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
2
+
3
+ this.document = {};
4
+ this.scope = {};
5
+ this.options = {};
6
+ this.isScenarioMode = null;
7
+ this.settings = {};
8
+
9
+ publishedItemsRenderer.formulaCellClicked = function (event, scope, options, window) {
10
+ event.stopPropagation();
11
+ event.preventDefault();
12
+ try {
13
+ const td = event.currentTarget;
14
+ const a = td.querySelector('a');
15
+ const locationId = a.getAttribute('location_id');
16
+ scope.callFromPublishItem(event, options.widgetId, options.dashboardId, locationId, window.published_item_sheetname);
17
+ } catch (e) {
18
+ }
19
+ return false;
20
+ }
21
+
22
+ publishedItemsRenderer.resizeTable = function (options, iframeWindow) {
23
+ const publish_item_image = iframeWindow.document.getElementById('publish_item_image');
24
+ const table = iframeWindow.document.getElementsByTagName("table")[0];
25
+ const body = iframeWindow.document.getElementsByTagName("body")[0];
26
+
27
+ if (table && options.responsive) {
28
+ publishedItemsRenderer.zoomTable(iframeWindow, table, body);
29
+ }
30
+
31
+ publishedItemsRenderer.resizePublishedImage(publish_item_image, iframeWindow, body);
32
+ }
33
+
34
+ publishedItemsRenderer.zoomTable = function (iframeWindow, table, body) {
35
+ const bodyZoom = parseFloat(body.style.zoom) || 1;
36
+ const SCROLL_OFFSET = 16;
37
+
38
+ const tableWidth = table.getBoundingClientRect().width * bodyZoom;
39
+ const tableHeight = table.getBoundingClientRect().height * bodyZoom;
40
+ const root = iframeWindow.document.documentElement;
41
+
42
+ let requiredZoom = (root.clientWidth - SCROLL_OFFSET) / tableWidth;
43
+ if (this.settings.resizeTableUsingBothDimensions) {
44
+ requiredZoom = Math.min(requiredZoom, (root.clientHeight - SCROLL_OFFSET) / tableHeight);
45
+ }
46
+
47
+ table.style.zoom = requiredZoom;
48
+ };
49
+
50
+ publishedItemsRenderer.resizePublishedImage = function (publish_item_image, iframeWindow, body) {
51
+ if (!publish_item_image) return;
52
+
53
+ let body_zoom = body.style.zoom;
54
+ body_zoom = parseFloat(body_zoom) || 1;
55
+
56
+ if (publish_item_image.style.height === '100%') {
57
+ publish_item_image.style.height = 'auto';
58
+ publish_item_image.style.width = '100%';
59
+ publish_item_image.style.marginTop = "";
60
+ setTimeout(function () {
61
+ publishedItemsRenderer.resizePublishedImage(publish_item_image, iframeWindow, body);
62
+ }, 10);
63
+ }
64
+
65
+ const imgPositionInfo = publish_item_image.getBoundingClientRect();
66
+ const height = (imgPositionInfo.height + imgPositionInfo.y * 2) * body_zoom;
67
+ if (height > iframeWindow.innerHeight) {
68
+ publish_item_image.style.height = '100%';
69
+ publish_item_image.style.width = 'auto';
70
+ } else if (height < iframeWindow.innerHeight) {
71
+ const temp = (iframeWindow.innerHeight - height) / 2;
72
+ publish_item_image.style.marginTop = (temp / body_zoom + imgPositionInfo.y) + "px";
73
+ }
74
+ }
75
+
76
+ publishedItemsRenderer.resetTableZoom = function (document) {
77
+ const table = document.getElementsByTagName("table")[0];
78
+ if (table) {
79
+ table.style.zoom = 1;
80
+ }
81
+ }
82
+
83
+ publishedItemsRenderer.changedAutoResize = function (options, iframeWindow, document) {
84
+ Object.assign(iframeWindow.__options__, options);
85
+ const table = document.getElementsByTagName("table")[0];
86
+ if (table) {
87
+ table.style.margin = options.responsive ? '0 auto' : '';
88
+ }
89
+
90
+ if (!options.responsive) {
91
+ publishedItemsRenderer.resetTableZoom(document);
92
+ } else {
93
+ publishedItemsRenderer.resizeTable(options, iframeWindow);
94
+ }
95
+ }
96
+
97
+ publishedItemsRenderer.changedInputValue = function (firstTime, scope, options) {
98
+ const input_values = [];
99
+ if (options.inputValuesData) {
100
+ for (let key in options.inputValuesData) {
101
+ input_values.push(options.inputValuesData[key]);
102
+ }
103
+ }
104
+
105
+ try {
106
+ scope.changedInputValues(input_values, options.widgetId, options.dashboardId, firstTime);
107
+ } catch (e) {
108
+ console.error(e);
109
+ }
110
+ }
111
+
112
+ publishedItemsRenderer.changedInputElement = function (event, scope, options) {
113
+ const inputElement = event.currentTarget;
114
+ const name = inputElement.getAttribute('name');
115
+ const metaData = options.inputValuesData ? options.inputValuesData[name] : null;
116
+ let newValue = inputElement.value;
117
+ if (metaData) {
118
+ if (metaData.type === 'editInput') {
119
+ newValue = parseFloat(newValue);
120
+ } else if (metaData.type === 'editInputPercent') {
121
+ newValue = parseFloat(newValue) + '%';
122
+ }
123
+
124
+ if (metaData.value !== newValue) {
125
+ metaData.value = newValue;
126
+ publishedItemsRenderer.changedInputValue(false, scope, options);
127
+ }
128
+ }
129
+ }
130
+
131
+ publishedItemsRenderer.createInputElement = function (tdElement, inputMetaData, formatValue, scope, options, document) {
132
+ const _this = this;
133
+ tdElement.innerHTML = '';
134
+ if (inputMetaData) {
135
+ switch (inputMetaData.type) {
136
+ case "editInput":
137
+ case "editInputPercent":
138
+ let inEl = document.createElement("INPUT");
139
+ let labelEl = document.createElement("LABEL");
140
+
141
+ if (inputMetaData.value === 'DR_INPUT') {
142
+ labelEl.innerText = null;
143
+ } else {
144
+ labelEl.innerText = inputMetaData.format ? formatValue('n', inputMetaData.format, inputMetaData.value).value : inputMetaData.value;
145
+ }
146
+ if (_this.isScenarioMode) {
147
+ labelEl.setAttribute("style", "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);margin: 6px;text-align: inherit;display: block; cursor: pointer;");
148
+ } else {
149
+ labelEl.setAttribute("style", "background: transparent;width: calc(100% - 15px);border: 0;margin: 6px;text-align: inherit;display: block; cursor: pointer;");
150
+ }
151
+ const onLabelClick = function (event, isScenarioMode) {
152
+ event.stopPropagation();
153
+ if (isScenarioMode) {
154
+ inEl.setAttribute("style", "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: block;");
155
+ } else {
156
+ inEl.setAttribute("style", "background: transparent;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: block;");
157
+ }
158
+ labelEl.style.display = 'none';
159
+ setTimeout(function () {
160
+ inEl.focus();
161
+ }, 1)
162
+ }
163
+ labelEl.addEventListener("click", (event) => onLabelClick(event, _this.isScenarioMode));
164
+
165
+ inEl.setAttribute("type", "number");
166
+ inEl.setAttribute("name", inputMetaData.name);
167
+ if (_this.isScenarioMode) {
168
+ inEl.setAttribute("style", "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: none;");
169
+ } else {
170
+ inEl.setAttribute("style", "background: transparent;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: none;");
171
+ }
172
+ inEl.value = inputMetaData.type === 'editInputPercent' ? parseFloat(inputMetaData.value.replace('%', '')) : inputMetaData.value;
173
+ inEl.addEventListener("focusout", function (event) {
174
+ event.preventDefault();
175
+ publishedItemsRenderer.changedInputElement(event, scope, options);
176
+ inEl.style.display = 'none';
177
+ labelEl.innerText = inputMetaData.format ? formatValue('n', inputMetaData.format, inEl.value).value : inputMetaData.value;
178
+ labelEl.style.display = 'block';
179
+ });
180
+ inEl.addEventListener("keyup", function (event) {
181
+ // Number 13 is the "Enter" key on the keyboard
182
+ if (event.keyCode === 13) {
183
+ // Cancel the default action, if needed
184
+ event.preventDefault();
185
+ publishedItemsRenderer.changedInputElement(event, scope, options);
186
+ inEl.style.display = 'none';
187
+ labelEl.innerText = inputMetaData.format ? formatValue('n', inputMetaData.format, inEl.value).value : inputMetaData.value;
188
+ labelEl.style.display = 'block';
189
+ }
190
+ });
191
+ tdElement.appendChild(inEl);
192
+ tdElement.appendChild(labelEl);
193
+ break;
194
+ case "dateInput":
195
+ let dateEl = document.createElement("DIV");
196
+ const format = inputMetaData.format ? inputMetaData.format.toUpperCase() : 'MM/DD/YYYY';
197
+ const formattedDate = formatValue('d', format, inputMetaData.value).value
198
+ if (_this.isScenarioMode) {
199
+ dateEl.innerHTML = '<label class="value dateInput" style="background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor:pointer;">' + formattedDate + '</label>';
200
+ } else {
201
+ dateEl.innerHTML = '<label class="value dateInput" style="cursor: pointer;">' + formattedDate + '</label>';
202
+ }
203
+ tdElement.appendChild(dateEl);
204
+ tdElement.classList.toggle("input-filter-list-td");
205
+ tdElement.setAttribute("name", inputMetaData.name);
206
+ tdElement.addEventListener("click", function (event) {
207
+ try {
208
+ scope.openDatePickerFromPublishedItem(event, options.widgetId, options.dashboardId, inputMetaData, format);
209
+ } catch (e) {
210
+ console.error(e);
211
+ }
212
+ })
213
+ break;
214
+ case "excelList":
215
+ let selectEl = document.createElement("SELECT");
216
+ selectEl.setAttribute("name", inputMetaData.name);
217
+ selectEl.setAttribute("class", "dr_input");
218
+ for (let i = 0; i < inputMetaData.values.length; i++) {
219
+ let option = document.createElement("option");
220
+ option.setAttribute("value", inputMetaData.values[i]);
221
+ option.innerText = inputMetaData.values[i];
222
+ if (inputMetaData.values[i] === inputMetaData.value) {
223
+ option.setAttribute("selected", "");
224
+ }
225
+ selectEl.appendChild(option);
226
+ }
227
+ selectEl.addEventListener("change", function (event) {
228
+ publishedItemsRenderer.changedInputElement(event, scope, options)
229
+ });
230
+ tdElement.appendChild(selectEl);
231
+ break;
232
+ case "filterList":
233
+ let listHolderEl = document.createElement("DIV");
234
+ listHolderEl.setAttribute("class", "filter_list_holder");
235
+ if (_this.isScenarioMode) {
236
+ listHolderEl.innerHTML = '<label class="value filterList" style="background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor: pointer;">' + inputMetaData.value + '</label><i class="filter_icon"></i>';
237
+ } else {
238
+ listHolderEl.innerHTML = '<label class="value filterList" style="cursor: pointer;">' + inputMetaData.value + '</label><i class="filter_icon"></i>';
239
+ }
240
+ tdElement.appendChild(listHolderEl);
241
+ tdElement.classList.toggle("input-filter-list-td");
242
+ tdElement.setAttribute("name", inputMetaData.name);
243
+ tdElement.addEventListener("click", function (event) {
244
+ let inputElement = event.currentTarget;
245
+ let name = inputElement.getAttribute('name');
246
+ let metaData = options.inputValuesData ? options.inputValuesData[name] : null;
247
+ if (metaData) {
248
+ try {
249
+ scope.openFilterListFromPublishedItem(event, options.widgetId, options.dashboardId, metaData);
250
+ } catch (e) {
251
+ console.error(e);
252
+ }
253
+ }
254
+ });
255
+ break;
256
+ }
257
+ }
258
+ }
259
+
260
+ publishedItemsRenderer.changedInputFilterValue = function (metaData, newValue, document) {
261
+ let tdLabelElement = document.querySelector('td[name="' + metaData.name + '"]>div>label[class="value"]');
262
+ if (tdLabelElement) {
263
+ tdLabelElement.innerText = newValue;
264
+ }
265
+ console.log(tdLabelElement, newValue);
266
+ }
267
+
268
+ publishedItemsRenderer.changeStylesForLabel = function (elementsArray, styles, isScenarioMode) {
269
+ if (elementsArray.length) {
270
+ elementsArray.forEach(element => {
271
+ element.setAttribute("style", isScenarioMode ? styles : "cursor:pointer;");
272
+ })
273
+ }
274
+ }
275
+
276
+ publishedItemsRenderer.prepareInputCells = function (document, scope, options, isScenarioMode) {
277
+ const inputCells = document.querySelectorAll('td>a[href="DR_INPUT"], td>div>a[href="DR_INPUT"]');
278
+ const inputs = document.querySelectorAll('td>input');
279
+ const dateInputs = document.querySelectorAll('.dateInput');
280
+ const filterList = document.querySelectorAll('.filterList');
281
+ const styleForLabel = "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor:pointer;";
282
+ if (!options.inputValuesData) {
283
+ options.inputValuesData = {};
284
+ }
285
+ publishedItemsRenderer.changeStylesForLabel(filterList, styleForLabel, isScenarioMode);
286
+ publishedItemsRenderer.changeStylesForLabel(dateInputs, styleForLabel, isScenarioMode);
287
+ if (inputs.length) {
288
+ inputs.forEach(element => {
289
+ const labelElement = element.nextSibling;
290
+ labelElement.setAttribute("style", isScenarioMode ?
291
+ "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);margin: 6px;text-align: inherit;display: block; cursor: pointer;" :
292
+ "background: transparent;width: calc(100% - 15px);border: 0;margin: 6px;text-align: inherit;display: block; cursor: pointer;");
293
+ });
294
+ }
295
+ if (inputCells.length) {
296
+ for (let i = 0; i < inputCells.length; i++) {
297
+ let tdElement = inputCells[i].parentElement;
298
+ let inputId = inputCells[i].getAttribute('name') || 'no_attribute';
299
+ publishedItemsRenderer.createInputElement(tdElement, options.inputValuesData[inputId], scope.highchartsRenderer.formatValue, scope, options, document, isScenarioMode);
300
+ }
301
+ }
302
+ }
303
+
304
+ publishedItemsRenderer.addEventListeners = function (document, iframeWindow, scope, options) {
305
+ let resizeTimeout;
306
+ const handleDimensionChange = () => {
307
+ if (resizeTimeout) {
308
+ cancelAnimationFrame(resizeTimeout);
309
+ }
310
+
311
+ resizeTimeout = requestAnimationFrame(() => {
312
+ publishedItemsRenderer.resizeTable(iframeWindow.__options__, iframeWindow);
313
+ });
314
+ }
315
+
316
+ document.addEventListener("DOMContentLoaded", handleDimensionChange);
317
+ iframeWindow.addEventListener("resize", handleDimensionChange);
318
+
319
+ // Add click event to cell with formula
320
+ let all_a_hrefs = document.querySelectorAll('td a[location_id]');
321
+ for (let i = 0; i < all_a_hrefs.length; i++) {
322
+ let td_elem = all_a_hrefs[i].closest('td');
323
+ td_elem.classList.add("apply_hover");
324
+ td_elem.addEventListener('click', function (event) {
325
+ publishedItemsRenderer.formulaCellClicked(event, scope, options, iframeWindow)
326
+ });
327
+ }
328
+ }
329
+
330
+ publishedItemsRenderer.scenarioModeChange = function (flag, document) {
331
+ this.isScenarioMode = flag;
332
+ publishedItemsRenderer.prepareInputCells(document, this.scope, this.options, this.isScenarioMode);
333
+ }
334
+
335
+ publishedItemsRenderer.getInputValues = function () {
336
+ return this.options.inputValuesData;
337
+ }
338
+
339
+ publishedItemsRenderer.initPublishedItem = function (document, iframeWindow, scope, options) {
340
+ this.document = document;
341
+ this.scope = scope;
342
+ this.options = options;
343
+ iframeWindow.__options__ = options;
344
+ publishedItemsRenderer.prepareInputCells(document, scope, options, this.isScenarioMode);
345
+ publishedItemsRenderer.applyInitDocumentStyles(document, iframeWindow);
346
+ publishedItemsRenderer.addEventListeners(document, iframeWindow, scope, options);
347
+
348
+ setTimeout(function () {
349
+ publishedItemsRenderer.changedInputValue(true, scope, options);
350
+ }, 500);
351
+ }
352
+
353
+ publishedItemsRenderer.applyInitDocumentStyles = function (document, iframeWindow) {
354
+ const table = document.getElementsByTagName('table')[0];
355
+ if (table) {
356
+ table.style.overflow = 'hidden';
357
+ table.style.margin = iframeWindow.__options__.responsive ? '0 auto' : '';
358
+ }
359
+
360
+ const body = document.body;
361
+ body.style.margin = '0';
362
+ }
363
+ }
364
+
365
+ module.exports = getPublishedItemsRenderer;
@@ -0,0 +1,43 @@
1
+ function getSeriesPointStyles(isSelected) {
2
+ return {
3
+ opacity: isSelected ? 1 : 0.1,
4
+ marker: {
5
+ enabled: true,
6
+ radius: isSelected ? 8 : 3,
7
+ },
8
+ dataLabels: {
9
+ style: {
10
+ fontWeight: isSelected ? "bold" : "normal",
11
+ },
12
+ },
13
+ };
14
+ }
15
+
16
+ function setSeriesPointStylesOnClick(e) {
17
+ const selectedPoint = e.point;
18
+ e.point.series.chart.series.forEach((series) =>
19
+ series.points.forEach((point) => {
20
+ point.update(getSeriesPointStyles(point === selectedPoint), false);
21
+ })
22
+ );
23
+ e.point.series.chart.redraw();
24
+ }
25
+
26
+ function setInitialPointStyles(opts, series) {
27
+ series.forEach((series) => {
28
+ if (Array.isArray(series.data)) {
29
+ series.data.forEach((item) => {
30
+ const isSelected =
31
+ item && opts.selectedPoint &&
32
+ item.initialName === opts.selectedPoint.initialName &&
33
+ item.y.toFixed(2) === opts.selectedPoint.y.toFixed(2);
34
+ item = Object.assign(item, getSeriesPointStyles(isSelected));
35
+ });
36
+ }
37
+ });
38
+ }
39
+
40
+ module.exports = {
41
+ setSeriesPointStylesOnClick,
42
+ setInitialPointStyles,
43
+ };
package/start_run.sh CHANGED
@@ -1,3 +1,3 @@
1
- #!/bin/bash
2
- source ~/.nvm/nvm.sh
3
- nvm use 14.15.1
1
+ #!/bin/bash
2
+ source ~/.nvm/nvm.sh
3
+ nvm use 14.15.1
@@ -0,0 +1,150 @@
1
+ import drRendererHelpers from '../src/dr-renderer-helpers';
2
+
3
+ describe('dr-renderer-helpers', () => {
4
+
5
+ describe('backendSortingKeysAreNotEmpty', () => {
6
+ it('should return true if keys are not empty', () => {
7
+ const keys = {
8
+ row_keys: [1, 2, 3],
9
+ col_keys: [1, 2, 3]
10
+ };
11
+ expect(drRendererHelpers.backendSortingKeysAreNotEmpty(keys)).toBe(true);
12
+ });
13
+
14
+ it('should return true if one of the keys is not empty', () => {
15
+ const keys = {
16
+ row_keys: [1, 2, 3],
17
+ col_keys: []
18
+ };
19
+ expect(drRendererHelpers.backendSortingKeysAreNotEmpty(keys)).toBe(true);
20
+ });
21
+
22
+ it('should return false if keys are empty', () => {
23
+ const keys = {
24
+ row_keys: [],
25
+ col_keys: [],
26
+ };
27
+ expect(drRendererHelpers.backendSortingKeysAreNotEmpty(keys)).toBe(false);
28
+ });
29
+
30
+ it('should return false if keys are null', () => {
31
+ const keys = null;
32
+ expect(drRendererHelpers.backendSortingKeysAreNotEmpty(keys)).toBe(false);
33
+ });
34
+ });
35
+
36
+ describe('capitalize', () => {
37
+ it('should capitalize a string', () => {
38
+ const string = 'test';
39
+ expect(drRendererHelpers.capitalize(string)).toBe('Test');
40
+ });
41
+
42
+ it('should not capitalize a string when it was not trimmed', () => {
43
+ const string = ' test';
44
+ expect(drRendererHelpers.capitalize(string)).toBe(' test');
45
+ });
46
+
47
+ it('should return an empty string if string is null', () => {
48
+ const string = null;
49
+ expect(drRendererHelpers.capitalize(string)).toBe('');
50
+ });
51
+ });
52
+
53
+ describe('clamp', () => {
54
+ it('should clamp value between teh boundaries', () => {
55
+ expect(drRendererHelpers.clamp(10, 5, 20)).toBe(10);
56
+ expect(drRendererHelpers.clamp(10, 25, 20)).toBe(20);
57
+ expect(drRendererHelpers.clamp(10, 15, 20)).toBe(15);
58
+ });
59
+ });
60
+
61
+ describe('isNumber', () => {
62
+ it('should check whether the value is a finity number', () => {
63
+ expect(drRendererHelpers.isNumber('number')).toBeFalsy();
64
+ expect(drRendererHelpers.isNumber(Infinity)).toBeFalsy();
65
+ expect(drRendererHelpers.isNumber(12)).toBeTruthy();
66
+ });
67
+ });
68
+
69
+ describe('mergeDeep', () => {
70
+ it('should handle the wrong data', () => {
71
+ expect(drRendererHelpers.mergeDeep([1, 2, 3], { a: 1, b: 2})).toEqual([1, 2, 3]);
72
+ expect(drRendererHelpers.mergeDeep('string', { a: 1, b: 2})).toEqual('string');
73
+ expect(drRendererHelpers.mergeDeep({ a: 1 }, 'string')).toEqual({ a: 1 });
74
+ });
75
+
76
+ it('should not merge arrays and replace instead', () => {
77
+ expect(drRendererHelpers.mergeDeep({
78
+ a: [1, 2, 3]
79
+ }, {
80
+ a: [2, 3, 4]
81
+ })).toEqual({
82
+ a: [2, 3, 4]
83
+ });
84
+ });
85
+
86
+ it('should merge nested objects', () => {
87
+ expect(drRendererHelpers.mergeDeep({
88
+ a: 1,
89
+ b: {
90
+ c: 3,
91
+ d: 4
92
+ }
93
+ },
94
+ {
95
+ b: {
96
+ d: 5,
97
+ e: 6
98
+ },
99
+ c: 7
100
+ })).toEqual({
101
+ a: 1,
102
+ b: {
103
+ c: 3,
104
+ d: 5,
105
+ e: 6,
106
+ },
107
+ c: 7,
108
+ });
109
+ });
110
+
111
+ it('should merge more than 2 objects', () => {
112
+ expect(drRendererHelpers.mergeDeep({
113
+ a: 1,
114
+ b: 2
115
+ },
116
+ {
117
+ b: 3,
118
+ c: 4
119
+ },
120
+ {
121
+ a: 5,
122
+ e: 6
123
+ })).toEqual({
124
+ a: 5,
125
+ b: 3,
126
+ c: 4,
127
+ e: 6
128
+ });
129
+ });
130
+ });
131
+
132
+ describe('removeSVGTextCorrection', () => {
133
+ it('should remove yCorr by default', () => {
134
+ const svg = {
135
+ yCorr: -12
136
+ };
137
+ drRendererHelpers.removeSVGTextCorrection(svg);
138
+ expect(svg.yCorr).toBe(0);
139
+ });
140
+
141
+ it('should remove yCorr by default', () => {
142
+ const svg = {
143
+ xCorr: -12
144
+ };
145
+ drRendererHelpers.removeSVGTextCorrection(svg, 'xCorr');
146
+ svg.xCorr = -20;
147
+ expect(svg.xCorr).toBe(0);
148
+ });
149
+ });
150
+ });