@datarailsshared/dr_renderer 1.4.99 → 1.4.105
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/package.json
CHANGED
package/src/value.formatter.js
CHANGED
@@ -7,7 +7,7 @@ function getAggregatorPercentageValueIfRequired(value, render_options, data, row
|
|
7
7
|
const isVariance = currentRowName.replace('_', '').toLowerCase() === deltaColumnName.replace('_', '').toLowerCase();
|
8
8
|
const baseRowKey = data && data.rowKeys && data.rowKeys.length ? data.rowKeys[0] : null;
|
9
9
|
const currentColKey = colKey ? colKey : [];
|
10
|
-
const agg = data ? data.getAggregator(baseRowKey, currentColKey) : null;
|
10
|
+
const agg = data && baseRowKey ? data.getAggregator(baseRowKey, currentColKey) : null;
|
11
11
|
|
12
12
|
if (isPercentage && isVariance && baseRowKey && agg) {
|
13
13
|
const baseValue = agg.value();
|
@@ -60,6 +60,26 @@ describe('Function getAggregatorPercentageValueIfRequired', () => {
|
|
60
60
|
const result = getAggregatorPercentageValueIfRequired(50, render_options, data, rowKey, colKey);
|
61
61
|
expect(result).toBeNull();
|
62
62
|
});
|
63
|
+
|
64
|
+
it('should return null if data is null', () => {
|
65
|
+
const result = getAggregatorPercentageValueIfRequired(50, render_options, null, rowKey, colKey);
|
66
|
+
expect(result).toBeNull();
|
67
|
+
});
|
68
|
+
|
69
|
+
it('should return null if data is undefined', () => {
|
70
|
+
const result = getAggregatorPercentageValueIfRequired(50, render_options, undefined, rowKey, colKey);
|
71
|
+
expect(result).toBeNull();
|
72
|
+
});
|
73
|
+
|
74
|
+
it('should return null if baseRowKey is null even when data exists', () => {
|
75
|
+
const data = {
|
76
|
+
rowKeys: [null],
|
77
|
+
getAggregator: jest.fn()
|
78
|
+
};
|
79
|
+
const result = getAggregatorPercentageValueIfRequired(50, render_options, data, rowKey, colKey);
|
80
|
+
expect(result).toBeNull();
|
81
|
+
expect(data.getAggregator).not.toHaveBeenCalled();
|
82
|
+
});
|
63
83
|
});
|
64
84
|
|
65
85
|
describe('Function getPercentageValue', () => {
|