@sis-cc/dotstatsuite-components 15.0.8 → 15.0.9

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.
@@ -19,7 +19,7 @@ var hierarchiseDimensionWithNativeHierarchy = exports.hierarchiseDimensionWithNa
19
19
  }, values);
20
20
 
21
21
  var getChildren = function getChildren(parents) {
22
- var childs = R.propOr([], R.last(parents) || '#ROOT', grouped);
22
+ var childs = R.propOr([], R.defaultTo('#ROOT', R.last(parents)), grouped);
23
23
  return R.reduce(function (acc, child) {
24
24
  var refined = R.pipe(R.assoc('parents', parents), R.assoc('parent', R.last(parents)))(child);
25
25
  var children = getChildren(R.append(child.id, parents));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sis-cc/dotstatsuite-components",
3
3
  "description": "Set components based on React.",
4
- "version": "15.0.8",
4
+ "version": "15.0.9",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -6,7 +6,7 @@ export const hierarchiseDimensionWithNativeHierarchy = (dimension) => {
6
6
  const grouped = R.groupBy(val => val.parent && R.has(val.parent, indexed) ? val.parent : '#ROOT', values);
7
7
 
8
8
  const getChildren = (parents) => {
9
- const childs = R.propOr([], R.last(parents) || '#ROOT', grouped);
9
+ const childs = R.propOr([], R.defaultTo('#ROOT', R.last(parents)), grouped);
10
10
  return R.reduce(
11
11
  (acc, child) => {
12
12
  const refined = R.pipe(
@@ -52,6 +52,31 @@ describe('hierarchiseDimensionWithNativeHierarchy tests', () => {
52
52
  ]
53
53
  };
54
54
 
55
+ expect(hierarchiseDimensionWithNativeHierarchy(dimension)).to.deep.equal(expected);
56
+ });
57
+ it ('empty id', () => {
58
+ const dimension = {
59
+ id: 'test',
60
+ values: [
61
+ { id: '', parent: '', __indexPosition: 101 },
62
+ { id: 'GER', parent: 'EA', __indexPosition: 100 },
63
+ { id: 'EA', parent: 'W', __indexPosition: 30 },
64
+ { id: 'A', parent: 'W', __indexPosition: 20 },
65
+ { id: 'CHI', parent: undefined, __indexPosition: 0 }
66
+ ]
67
+ };
68
+
69
+ const expected = {
70
+ id: 'test',
71
+ values: [
72
+ { id: 'CHI', parent: undefined, parents: [], __indexPosition: 0 },
73
+ { id: 'A', parent: undefined, parents: [], __indexPosition: 20 },
74
+ { id: 'EA', parent: undefined, parents: [], __indexPosition: 30 },
75
+ { id: 'GER', parent: 'EA', parents: ['EA'], __indexPosition: 100 },
76
+ { id: '', parent: '', parents: [''], __indexPosition: 101 }
77
+ ]
78
+ };
79
+
55
80
  expect(hierarchiseDimensionWithNativeHierarchy(dimension)).to.deep.equal(expected);
56
81
  });
57
82
  });