@datarailsshared/dr_renderer 1.4.121 → 1.4.128

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.4.121",
3
+ "version": "1.4.128",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -31,7 +31,7 @@ function isAbsoluteValue(formula) {
31
31
  if (!formula)
32
32
  return false;
33
33
 
34
- return lodash.includes(formula.replace(/\s+/g, ''), 'x2-x1');
34
+ return !lodash.includes(formula.replace(/\s+/g, ''), '/');
35
35
  };
36
36
 
37
37
  module.exports = {
@@ -9,7 +9,8 @@ describe('Function getAggregatorPercentageValueIfRequired', () => {
9
9
  chartOptions: {
10
10
  delta_column: {
11
11
  name: 'Variance',
12
- formula: 'x2-x1'
12
+ formula: 'x2-x1',
13
+ is_percentage: false
13
14
  }
14
15
  }
15
16
  };
@@ -17,7 +18,7 @@ describe('Function getAggregatorPercentageValueIfRequired', () => {
17
18
  colKey = ['SomeCol'];
18
19
  });
19
20
 
20
- it('should return percentage string when all conditions are met', () => {
21
+ it('should return percentage string when secondaryAxisSettings.is_percentage is true but delta_column.is_percentage is false', () => {
21
22
  const data = {
22
23
  rowKeys: ['Variance'],
23
24
  getAggregator: jest.fn(() => ({
@@ -28,6 +29,19 @@ describe('Function getAggregatorPercentageValueIfRequired', () => {
28
29
  expect(result).toBe('25%');
29
30
  });
30
31
 
32
+ it('should return percentage string when secondaryAxisSettings.is_percentage is false but delta_column.is_percentage is true', () => {
33
+ const data = {
34
+ rowKeys: ['Variance'],
35
+ getAggregator: jest.fn(() => ({
36
+ value: () => 200
37
+ }))
38
+ };
39
+ render_options.comboOptions.secondaryAxisSettings.is_percentage = false;
40
+ render_options.chartOptions.delta_column.is_percentage = true;
41
+ const result = getAggregatorPercentageValueIfRequired(50, render_options, data, rowKey, colKey);
42
+ expect(result).toBe('25%');
43
+ });
44
+
31
45
  it('should return null if is_percentage is false', () => {
32
46
  const data = {
33
47
  rowKeys: ['Variance'],
@@ -111,20 +125,19 @@ describe('Function isAbsoluteValue', () => {
111
125
  expect(isAbsoluteValue(null)).toBe(false);
112
126
  });
113
127
 
114
- it('should return false if formula does not contain "x2-x1"', () => {
115
- expect(isAbsoluteValue('x2 + x1')).toBe(false);
116
- expect(isAbsoluteValue('x1-x2')).toBe(false);
117
- expect(isAbsoluteValue('')).toBe(false);
128
+ it('should return false if formula contains "/"', () => {
129
+ expect(isAbsoluteValue('/')).toBe(false);
130
+ expect(isAbsoluteValue(' / ')).toBe(false);
118
131
  });
119
132
 
120
- it('should return true if formula contains "x2-x1"', () => {
133
+ it('should return true if formula does not contain "/"', () => {
121
134
  expect(isAbsoluteValue('x2-x1')).toBe(true);
122
- expect(isAbsoluteValue(' x2 - x1 ')).toBe(true);
135
+ expect(isAbsoluteValue(' x1 - x2 ')).toBe(true);
123
136
  expect(isAbsoluteValue('some text x2-x1 more text')).toBe(true);
124
137
  });
125
138
 
126
139
  it('should ignore spaces in formula', () => {
127
140
  expect(isAbsoluteValue('x2 - x1')).toBe(true);
128
- expect(isAbsoluteValue(' x2 - x1 ')).toBe(true);
141
+ expect(isAbsoluteValue(' x1 - x2 ')).toBe(true);
129
142
  });
130
143
  });