@datarailsshared/dr_renderer 1.5.159 → 1.5.168
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.
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/misc.xml +9 -0
- package/.nvmrc +1 -0
- package/jest.config.js +1 -1
- package/package.json +9 -11
- package/scripts/check-versions.js +16 -0
- package/src/highcharts_renderer.d.ts +2 -2
- package/tsconfig.json +1 -1
- package/.circleci/config.yml +0 -85
- package/.github/workflows/ai-coder-jira.yml +0 -915
- package/.github/workflows/ai-coder-n8n-caller.yml +0 -82
- package/.github/workflows/release.yml +0 -49
- package/tests/__snapshots__/suboptions.test.js.snap +0 -5028
- package/tests/dr-renderer-helpers.test.js +0 -228
- package/tests/dr_chart_tooltip.test.js +0 -789
- package/tests/dr_gauge_chart.test.js +0 -2041
- package/tests/errors.test.js +0 -157
- package/tests/highcharts_renderer.test.js +0 -9407
- package/tests/mock/add-in-dynamic-ranges.json +0 -127
- package/tests/mock/add-in-functions.json +0 -410
- package/tests/mock/add-in-tables.json +0 -347
- package/tests/mock/tables.json +0 -2258
- package/tests/mock/widgets.json +0 -401
- package/tests/options-builder.test.js +0 -1698
- package/tests/pivot-table/freeze-panes/constants.test.js +0 -92
- package/tests/pivot-table/freeze-panes/index.test.js +0 -193
- package/tests/pivot-table/freeze-panes/sticky-strategy.test.js +0 -542
- package/tests/pivot-table/freeze-panes/transform-strategy.test.js +0 -304
- package/tests/ptCreateDrillDownSeriesToDrilldownChart.test.js +0 -509
- package/tests/seriesPointStyles-helper.test.js +0 -114
- package/tests/suboptions.test.js +0 -322
- package/tests/value.formatter.test.js +0 -143
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import drRendererHelpers from '../src/dr-renderer-helpers';
|
|
2
|
-
|
|
3
|
-
describe('dr-renderer-helpers', () => {
|
|
4
|
-
describe('capitalize', () => {
|
|
5
|
-
it('should capitalize a string', () => {
|
|
6
|
-
const string = 'test';
|
|
7
|
-
expect(drRendererHelpers.capitalize(string)).toBe('Test');
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should not capitalize a string when it was not trimmed', () => {
|
|
11
|
-
const string = ' test';
|
|
12
|
-
expect(drRendererHelpers.capitalize(string)).toBe(' test');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should return an empty string if string is null', () => {
|
|
16
|
-
const string = null;
|
|
17
|
-
expect(drRendererHelpers.capitalize(string)).toBe('');
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe('clamp', () => {
|
|
22
|
-
it('should clamp value between teh boundaries', () => {
|
|
23
|
-
expect(drRendererHelpers.clamp(10, 5, 20)).toBe(10);
|
|
24
|
-
expect(drRendererHelpers.clamp(10, 25, 20)).toBe(20);
|
|
25
|
-
expect(drRendererHelpers.clamp(10, 15, 20)).toBe(15);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe('isNumber', () => {
|
|
30
|
-
it('should check whether the value is a finity number', () => {
|
|
31
|
-
expect(drRendererHelpers.isNumber('number')).toBeFalsy();
|
|
32
|
-
expect(drRendererHelpers.isNumber(Infinity)).toBeFalsy();
|
|
33
|
-
expect(drRendererHelpers.isNumber(12)).toBeTruthy();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe('mergeDeep', () => {
|
|
38
|
-
it('should handle the wrong data', () => {
|
|
39
|
-
expect(drRendererHelpers.mergeDeep([1, 2, 3], { a: 1, b: 2})).toEqual([1, 2, 3]);
|
|
40
|
-
expect(drRendererHelpers.mergeDeep('string', { a: 1, b: 2})).toEqual('string');
|
|
41
|
-
expect(drRendererHelpers.mergeDeep({ a: 1 }, 'string')).toEqual({ a: 1 });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('does not mutate sources', () => {
|
|
45
|
-
const src1 = { a: { x: 1 }, arr: [1,2] };
|
|
46
|
-
const src2 = { a: { y: 2 }, arr: [3] };
|
|
47
|
-
const res = drRendererHelpers.mergeDeep({}, src1, src2);
|
|
48
|
-
|
|
49
|
-
res.a.x = 42;
|
|
50
|
-
res.arr.push(99);
|
|
51
|
-
|
|
52
|
-
expect(src1).toEqual({ a: { x: 1 }, arr: [1,2] });
|
|
53
|
-
expect(src2).toEqual({ a: { y: 2 }, arr: [3] });
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('replaces arrays by clone, not by reference', () => {
|
|
57
|
-
const src = { a: [1,2,3] };
|
|
58
|
-
const res = drRendererHelpers.mergeDeep({}, src);
|
|
59
|
-
expect(res.a).not.toBe(src.a);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('ignores non-plain objects', () => {
|
|
63
|
-
const d = new Date();
|
|
64
|
-
const res = drRendererHelpers.mergeDeep({}, { when: d });
|
|
65
|
-
expect(res.when).toBe(d);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('last source wins (and arrays are replaced)', () => {
|
|
69
|
-
const res = drRendererHelpers.mergeDeep(
|
|
70
|
-
{ a: { x: 1 }, arr: [1] },
|
|
71
|
-
{ a: { y: 2 }, arr: [2] },
|
|
72
|
-
{ a: { z: 3 }, arr: [3] },
|
|
73
|
-
);
|
|
74
|
-
expect(res).toEqual({ a: { x:1, y:2, z:3 }, arr: [3] });
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should not merge arrays and replace instead', () => {
|
|
78
|
-
expect(drRendererHelpers.mergeDeep({
|
|
79
|
-
a: [1, 2, 3]
|
|
80
|
-
}, {
|
|
81
|
-
a: [2, 3, 4]
|
|
82
|
-
})).toEqual({
|
|
83
|
-
a: [2, 3, 4]
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('should merge nested objects', () => {
|
|
88
|
-
expect(drRendererHelpers.mergeDeep({
|
|
89
|
-
a: 1,
|
|
90
|
-
b: {
|
|
91
|
-
c: 3,
|
|
92
|
-
d: 4
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
b: {
|
|
97
|
-
d: 5,
|
|
98
|
-
e: 6
|
|
99
|
-
},
|
|
100
|
-
c: 7
|
|
101
|
-
})).toEqual({
|
|
102
|
-
a: 1,
|
|
103
|
-
b: {
|
|
104
|
-
c: 3,
|
|
105
|
-
d: 5,
|
|
106
|
-
e: 6,
|
|
107
|
-
},
|
|
108
|
-
c: 7,
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('should merge more than 2 objects', () => {
|
|
113
|
-
expect(drRendererHelpers.mergeDeep({
|
|
114
|
-
a: 1,
|
|
115
|
-
b: 2
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
b: 3,
|
|
119
|
-
c: 4
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
a: 5,
|
|
123
|
-
e: 6
|
|
124
|
-
})).toEqual({
|
|
125
|
-
a: 5,
|
|
126
|
-
b: 3,
|
|
127
|
-
c: 4,
|
|
128
|
-
e: 6
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('removeSVGTextCorrection', () => {
|
|
134
|
-
it('should remove yCorr by default', () => {
|
|
135
|
-
const svg = {
|
|
136
|
-
yCorr: -12
|
|
137
|
-
};
|
|
138
|
-
drRendererHelpers.removeSVGTextCorrection(svg);
|
|
139
|
-
expect(svg.yCorr).toBe(0);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should remove yCorr by default', () => {
|
|
143
|
-
const svg = {
|
|
144
|
-
xCorr: -12
|
|
145
|
-
};
|
|
146
|
-
drRendererHelpers.removeSVGTextCorrection(svg, 'xCorr');
|
|
147
|
-
svg.xCorr = -20;
|
|
148
|
-
expect(svg.xCorr).toBe(0);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
describe('disableLegendInteractionIfRequired', () => {
|
|
153
|
-
const notPieTypes = ['column', 'line', 'area', 'areaspline', 'scatter', 'spline', 'bar', 'waterfall'];
|
|
154
|
-
|
|
155
|
-
it('should not update legend settings', () => {
|
|
156
|
-
const chartOptionsMock = {
|
|
157
|
-
chart: {
|
|
158
|
-
type: 'column',
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
const additionOptionsMock = {
|
|
162
|
-
disable_legend_interaction: false,
|
|
163
|
-
};
|
|
164
|
-
drRendererHelpers.disableLegendInteractionIfRequired(chartOptionsMock, additionOptionsMock);
|
|
165
|
-
expect(chartOptionsMock.plotOptions).toBeFalsy();
|
|
166
|
-
expect(chartOptionsMock.legend).toBeFalsy();
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('should update legend styles and set click event (for pie chart)', () => {
|
|
170
|
-
const chartOptionsMock = {
|
|
171
|
-
chart: {
|
|
172
|
-
type: 'pie',
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
const additionOptionsMock = {
|
|
176
|
-
disable_legend_interaction: true,
|
|
177
|
-
};
|
|
178
|
-
drRendererHelpers.disableLegendInteractionIfRequired(chartOptionsMock, additionOptionsMock);
|
|
179
|
-
expect(chartOptionsMock.plotOptions.pie.point.events.legendItemClick).toEqual(jasmine.any(Function));
|
|
180
|
-
expect(chartOptionsMock.legend.itemStyle.cursor).toEqual('default');
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
notPieTypes.forEach((chartType) => {
|
|
184
|
-
it(`should update legend styles and set click event (for ${ chartType } chart)`, () => {
|
|
185
|
-
const chartOptionsMock = {
|
|
186
|
-
chart: {
|
|
187
|
-
type: chartType,
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
const additionOptionsMock = {
|
|
191
|
-
disable_legend_interaction: true,
|
|
192
|
-
};
|
|
193
|
-
drRendererHelpers.disableLegendInteractionIfRequired(chartOptionsMock, additionOptionsMock);
|
|
194
|
-
expect(chartOptionsMock.plotOptions.series.events.legendItemClick).toEqual(jasmine.any(Function));
|
|
195
|
-
expect(chartOptionsMock.legend.itemStyle.cursor).toEqual('default');
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
describe('isShowingEmptyValues', () => {
|
|
201
|
-
it('should return true when additionOptions is undefined', () => {
|
|
202
|
-
expect(drRendererHelpers.isShowingEmptyValues(undefined)).toBe(true);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it('should return true when additionOptions is null', () => {
|
|
206
|
-
expect(drRendererHelpers.isShowingEmptyValues(null)).toBe(true);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('should return true when additionOptions.chart is undefined', () => {
|
|
210
|
-
expect(drRendererHelpers.isShowingEmptyValues({})).toBe(true);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('should return true when dislay_empty_values is not false', () => {
|
|
214
|
-
expect(drRendererHelpers.isShowingEmptyValues({ chart: {} })).toBe(true);
|
|
215
|
-
expect(drRendererHelpers.isShowingEmptyValues({ chart: { dislay_empty_values: true } })).toBe(true);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('should return false when dislay_empty_values is false', () => {
|
|
219
|
-
expect(drRendererHelpers.isShowingEmptyValues({ chart: { dislay_empty_values: false } })).toBe(false);
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
describe('DELIMER', () => {
|
|
224
|
-
it('should be " , "', () => {
|
|
225
|
-
expect(drRendererHelpers.DELIMER).toBe(' , ');
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
});
|