@sis-cc/dotstatsuite-components 9.1.2 → 9.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.
Files changed (77) hide show
  1. package/lib/rules/src/preparators/enhanceObservations.js +155 -0
  2. package/lib/rules/src/preparators/formatValue.js +77 -0
  3. package/lib/rules/src/preparators/getDimensions.js +55 -0
  4. package/lib/rules/src/preparators/getDisplay.js +32 -0
  5. package/lib/rules/src/preparators/getObservations.js +27 -0
  6. package/lib/rules/src/table/factories/getCells.js +1 -3
  7. package/lib/rules/src/table/factories/getLayoutData.js +118 -159
  8. package/lib/rules/src/table/factories/getSortedLayoutIndexes.js +118 -0
  9. package/lib/rules/src/table/factories/getTableData.js +12 -10
  10. package/lib/rules/src/table/factories/refineLayoutSize.js +210 -0
  11. package/lib/rules/src/table/preparators/prepareData.js +23 -23
  12. package/lib/rules/src/table/units/getAttachmentSeriesIndexes.js +1 -1
  13. package/lib/rules/src/table/units/getUnitsSeries.js +31 -0
  14. package/lib/rules/src/v8-transformer.js +2 -1
  15. package/package.json +2 -2
  16. package/src/rules/src/preparators/enhanceObservations.js +163 -0
  17. package/src/rules/src/preparators/formatValue.js +73 -0
  18. package/src/rules/src/preparators/getDimensions.js +49 -0
  19. package/src/rules/src/preparators/getDisplay.js +20 -0
  20. package/src/rules/src/preparators/getObservations.js +19 -0
  21. package/src/rules/src/table/factories/getCells.js +3 -7
  22. package/src/rules/src/table/factories/getLayoutData.js +150 -184
  23. package/src/rules/src/table/factories/getSortedLayoutIndexes.js +108 -0
  24. package/src/rules/src/table/factories/getTableData.js +10 -10
  25. package/src/rules/src/table/factories/refineLayoutSize.js +224 -0
  26. package/src/rules/src/table/preparators/prepareData.js +23 -32
  27. package/src/rules/src/table/units/getAttachmentSeriesIndexes.js +2 -1
  28. package/src/rules/src/table/units/getUnitsSeries.js +20 -0
  29. package/src/rules/src/v8-transformer.js +2 -1
  30. package/test/appendUnitsInLayoutDataEntry.test.js +3 -3
  31. package/test/enhanceObservations.test.js +270 -0
  32. package/test/getAttachmentSeriesIndexes.test.js +1 -1
  33. package/test/getCells.test.js +4 -39
  34. package/test/getLayoutData.test.js +193 -298
  35. package/test/getOneValueDimensions.test.js +1 -1
  36. package/test/getSortedLayoutIndexes.test.js +80 -0
  37. package/test/getUnitsArtefacts.test.js +1 -1
  38. package/test/getUnitsSeries.test.js +64 -0
  39. package/test/mocks/table-layout-multi-hierarchies--layout.json +621 -0
  40. package/test/mocks/table-layout-multi-hierarchies--layoutData.json +32410 -0
  41. package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +2760 -0
  42. package/test/mocks/table-layout-multi-hierarchies--observations.json +30688 -0
  43. package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +2761 -0
  44. package/test/mocks/table-layout-truncation1--layout.json +27469 -0
  45. package/test/mocks/table-layout-truncation1--layoutData.json +20357 -0
  46. package/test/mocks/table-layout-truncation1--layoutIndexes.json +7512 -0
  47. package/test/mocks/table-layout-truncation1--observations.json +70002 -0
  48. package/test/mocks/table-layout-truncation1--sizedIndexes.json +3010 -0
  49. package/test/mocks/table-prep-multi-hierarchies--attributes.json +44 -0
  50. package/test/mocks/table-prep-multi-hierarchies--dimensions.json +688 -0
  51. package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +19696 -0
  52. package/test/mocks/table-prep-multi-hierarchies--observations.json +8246 -0
  53. package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +2985 -0
  54. package/test/mocks/table-prep-truncation1--dimensions.json +35057 -0
  55. package/test/mocks/table-prep-truncation1--enhancedObservations.json +70002 -0
  56. package/test/mocks/table-prep-truncation1--observations.json +27502 -0
  57. package/test/mocks/table-prep-truncation1--sdmxJson.json +55103 -0
  58. package/test/mocks/table-prep-units--observations.json +284286 -0
  59. package/test/mocks/table-prep-units--unitsSeries.json +41042 -0
  60. package/test/parseAttributes.test.js +1 -1
  61. package/test/refineLayoutSize.test.js +415 -0
  62. package/test/table-layout-perf.test.js +74 -0
  63. package/test/table-prep-perf.test.js +65 -0
  64. package/lib/rules/src/table/factories/getSortedLayoutData.js +0 -145
  65. package/lib/rules/src/table/factories/refineLayoutHierarchy.js +0 -61
  66. package/lib/rules/src/table/preparators/parseObservations.js +0 -76
  67. package/lib/rules/src/table/units/getUnitsSeriesOccurences.js +0 -39
  68. package/src/rules/src/table/factories/getSortedLayoutData.js +0 -133
  69. package/src/rules/src/table/factories/refineLayoutHierarchy.js +0 -64
  70. package/src/rules/src/table/preparators/parseObservations.js +0 -81
  71. package/src/rules/src/table/units/getUnitsSeriesOccurences.js +0 -51
  72. package/test/appendUnitsInLayoutData.test.js +0 -248
  73. package/test/getSortedLayoutData.test.js +0 -382
  74. package/test/getUnitsSeriesOccurences.test.js +0 -133
  75. package/test/parseObservations.test.js +0 -116
  76. package/test/refineDimSeriesUnits.test.js +0 -24
  77. package/test/refineLayoutHierarchy.test.js +0 -79
@@ -8,49 +8,13 @@ const customAttributes = {
8
8
  footnotes: ['FT1', 'FT2', 'FT3']
9
9
  };
10
10
 
11
- const data = {
12
- observations: {
13
- a: { value: 2, units: {}, indexedDimValIds: {} },
14
- b: { value: 0, units: {}, attributes: { T: { id: 'T', name: 'Toto', value: { id: 'A', name: 'Africa' } } }, indexedDimValIds: {} },
15
- c: { value: 10, units: {}, prefscale: 'Z', indexedDimValIds: {} },
16
- d: { value: 5, units: {}, prefscale: '0', indexedDimValIds: {} },
17
- e: { value: 8.3, units: {}, prefscale: '-1', indexedDimValIds: {} },
18
- f: { value: 25.62, units: {}, prefscale: '3', indexedDimValIds: {} },
19
- g: { value: 3.7, units: {}, decimals: 'AB', indexedDimValIds: {} },
20
- h: { value: 21.1234567, units: {}, decimals: '3', indexedDimValIds: {} },
21
- i: { value: 20.1, units: {}, decimals: '5', indexedDimValIds: {} },
22
- j: { value: 19.9, units: {}, decimals: '0', indexedDimValIds: {} },
23
- k: { value: 16.35, units: {}, decimals: '2', prefscale: '1', indexedDimValIds: {} },
24
- l: { value: 155062.56, units: {}, decimals: '3', indexedDimValIds: {} },
25
- m: { value: 155062.56, units: {}, decimals: '0', indexedDimValIds: {} },
26
- n: { value: null, units: {}, indexedDimValIds: {} },
27
- }
28
- };
29
-
30
11
  describe('getCells tests', () => {
31
- it('value format tests', () => {
32
- expect(getCells(data, 'label', customAttributes)).to.deep.equal({
33
- a: { value: '2', intValue: 2, flags: [], indexedDimValIds: {} },
34
- b: { value: '0', intValue: 0, flags: [{ label: 'Toto: Africa' }], indexedDimValIds: {} },
35
- c: { value: '10', intValue: 10, flags: [], indexedDimValIds: {} },
36
- d: { value: '5', intValue: 5, flags: [], indexedDimValIds: {} },
37
- e: { value: '83', intValue: 8.3, flags: [], indexedDimValIds: {} },
38
- f: { value: '0.02562', intValue: 25.62, flags: [], indexedDimValIds: {} },
39
- g: { value: '3.7', intValue: 3.7, flags: [], indexedDimValIds: {} },
40
- h: { value: '21.123', intValue: 21.1234567, flags: [], indexedDimValIds: {} },
41
- i: { value: '20.10000', intValue: 20.1, flags: [], indexedDimValIds: {} },
42
- j: { value: '20', intValue: 19.9, flags: [], indexedDimValIds: {} },
43
- k: { value: '1.64', intValue: 16.35, flags: [], indexedDimValIds: {} },
44
- l: { value: '155,062.560', intValue: 155062.56, flags: [], indexedDimValIds: {} },
45
- m: { value: '155,063', intValue: 155062.56, flags: [], indexedDimValIds: {} },
46
- n: { value: '..', intValue: null, flags: [], indexedDimValIds: {} },
47
- });
48
- });
49
12
  it('flags display name', () => {
50
13
  expect(getCells({
51
14
  observations: {
52
15
  a: {
53
16
  value: 33,
17
+ formattedValue: '33',
54
18
  attributes: {
55
19
  FL2: { id: 'FL2', name: 'Flag 2', value: { id: 'FL2.1', name: 'Flag 2 Value 1' } },
56
20
  FT1: { id: 'FT1', name: 'Footnote 1', value: { id: 'FT1.1', name: 'Footnote 1 Value 1' } },
@@ -78,6 +42,7 @@ describe('getCells tests', () => {
78
42
  observations: {
79
43
  a: {
80
44
  value: 33,
45
+ formattedValue: '33',
81
46
  attributes: {
82
47
  FL2: { id: 'FL2', name: 'Flag 2', value: { id: 'FL2.1', name: 'Flag 2 Value 1' } },
83
48
  FT1: { id: 'FT1', name: 'Footnote 1', value: { id: 'FT1.1', name: 'Footnote 1 Value 1' } },
@@ -99,7 +64,7 @@ describe('getCells tests', () => {
99
64
  }
100
65
  })
101
66
  });
102
- it('string observation type display test', () => {
67
+ /*it('string observation type display test', () => {
103
68
  expect(getCells({
104
69
  observations: {
105
70
  a: { value: '16.35', units: {}, decimals: '2', prefscale: '1', indexedDimValIds: {} },
@@ -109,5 +74,5 @@ describe('getCells tests', () => {
109
74
  a: { value: '16.35', intValue: '16.35', flags: [], indexedDimValIds: {} },
110
75
  b: { value: '155062.56', intValue: '155062.56', flags: [], indexedDimValIds: {} },
111
76
  })
112
- });
77
+ });*/
113
78
  });
@@ -1,311 +1,206 @@
1
1
  import { expect } from 'chai';
2
2
  import { getLayoutData } from '../src/rules/src/table/factories/getLayoutData';
3
3
 
4
- const formatLayoutData = (d, v) => ({ dimension: { __index: d }, value: { __index: v, __indexPosition: v } });
5
-
6
- const emptyHeadersLayout1 = {
7
- header: [],
8
- sections: [],
9
- rows: [
10
- { __index: 0, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] },
11
- { __index: 1, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] },
12
- { __index: 2, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] },
13
- ]
14
- };
15
-
16
- const emptyRowsLayout = {
17
- header: [
18
- { __index: 0, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] },
19
- { __index: 1, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] },
20
- { __index: 2, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] },
21
- ],
22
- sections: [],
23
- rows: [],
24
- };
25
-
26
- const simpleLayout = {
27
- header: [{ __index: 0, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] }],
28
- sections: [{ __index: 1, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] }],
29
- rows: [{ __index: 2, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] }]
30
- };
31
-
32
- const noSectionsLayout = {
33
- header: [
34
- { __index: 0, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] },
35
- { __index: 1, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] }
36
- ],
37
- sections: [],
38
- rows: [{ __index: 2, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] }],
39
- };
40
-
41
- const expectedSimpleLayoutData = {
42
- truncated: false,
43
- headerData: [
44
- [formatLayoutData(0, 0)],
45
- [formatLayoutData(0, 1)],
46
- [formatLayoutData(0, 2)]
47
- ],
48
- sectionsData: [
49
- [
50
- [formatLayoutData(1, 0)],
51
- [
52
- [formatLayoutData(2, 0)],
53
- [formatLayoutData(2, 1)],
54
- [formatLayoutData(2, 2)]
55
- ]
56
- ],
57
- [
58
- [formatLayoutData(1, 1)],
59
- [
60
- [formatLayoutData(2, 0)],
61
- [formatLayoutData(2, 1)],
62
- [formatLayoutData(2, 2)]
63
- ]
64
- ],
65
- [
66
- [formatLayoutData(1, 2)],
67
- [
68
- [formatLayoutData(2, 0)],
69
- [formatLayoutData(2, 1)],
70
- [formatLayoutData(2, 2)]
71
- ]
72
- ]
73
- ]
74
- };
75
-
76
- const expectedRefinedAfterEmptyRowsClean = {
77
- truncated:true,
78
- headerData: [
79
- [formatLayoutData(0, 0), formatLayoutData(1, 0)],
80
- [formatLayoutData(0, 0), formatLayoutData(1, 1)],
81
- [formatLayoutData(0, 0), formatLayoutData(1, 2)],
82
- [formatLayoutData(0, 1), formatLayoutData(1, 0)],
83
- [formatLayoutData(0, 1), formatLayoutData(1, 1)],
84
- [formatLayoutData(0, 1), formatLayoutData(1, 2)],
85
- ],
86
- sectionsData: [
87
- [
88
- [],
89
- [
90
- [formatLayoutData(2, 0)],
4
+ describe('getLayoutData tests', () => {
5
+ it ('simple single row diension case', () => {
6
+ const layout = {
7
+ header: [],
8
+ sections: [],
9
+ rows: [{ id: 'd0', values: [{ id: '0v0' }, { id: '0v1' }] }]
10
+ };
11
+
12
+ const indexes = {
13
+ truncated: false,
14
+ header: [],
15
+ sections: [[[], [[0], [1]]]]
16
+ };
17
+
18
+ const expected = {
19
+ truncated: false,
20
+ headerData: [],
21
+ sectionsData: [
22
+ [
23
+ [],
24
+ [[{ dimension: { id: 'd0' }, value: { id: '0v0' } }], [{ dimension: { id: 'd0' }, value: { id: '0v1' } }]]
25
+ ]
91
26
  ]
92
- ]
93
- ]
94
- };
27
+ };
95
28
 
96
- const expectedRefinedAfterEmptyHeaderClean = {
97
- truncated: true,
98
- headerData: [
99
- [formatLayoutData(0, 0)],
100
- [formatLayoutData(0, 2)]
101
- ],
102
- sectionsData: [
103
- [
104
- [formatLayoutData(1, 0)],
105
- [
106
- [formatLayoutData(2, 0)],
107
- [formatLayoutData(2, 1)],
108
- [formatLayoutData(2, 2)]
29
+ expect(getLayoutData(indexes, layout)).to.deep.equal(expected);
30
+ });
31
+ it('complete case', () => {
32
+ const layout = {
33
+ header: [{ id: 'd0', values: [{ id: '0v0' }, { id: '0v1' }] }],
34
+ sections: [{ id: 'd1', values: [{ id: '1v0' }, { id: '1v1' }] }],
35
+ rows: [
36
+ {
37
+ id: 'd2', values: [
38
+ { id: '2v0', name: '2V0' },
39
+ { id: '2v0.0', name: '2V0.0', parents: ['2v0'] },
40
+ { id: '2v0.0.0', name: '2V0.0.0', parents: ['2v0', '2v0.0'] },
41
+ { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] }
42
+ ]
43
+ },
44
+ {
45
+ id: 'd3', values: [
46
+ { id: '3v0', name: '3V0' },
47
+ { id: '3v0.0', name: '3V0.0', parents: ['3v0'] },
48
+ { id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] },
49
+ { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] },
50
+ { id: '3v0.1', name: '3V0.1', parents: ['3v0'] },
51
+ { id: '3v0.1.0', name: '3V0.1.0', parents: ['3v0', '3v0.1'] }
52
+ ]
53
+ },
109
54
  ]
110
- ],
111
- [
112
- [formatLayoutData(1, 1)],
113
- [
114
- [formatLayoutData(2, 0)],
115
- [formatLayoutData(2, 1)],
116
- [formatLayoutData(2, 2)]
55
+ };
56
+
57
+ const indexes = {
58
+ truncated: false,
59
+ header: [[0], [1]],
60
+ sections: [
61
+ [
62
+ [0],
63
+ [
64
+ [0, 0],
65
+ [0, 1],
66
+ [0, 2],
67
+ [0, 3],
68
+ [1, 0],
69
+ [1, 1],
70
+ [1, 2],
71
+ [1, 3],
72
+ [2, 0],
73
+ [2, 1],
74
+ [2, 2],
75
+ [2, 3],
76
+ [3, 0],
77
+ [3, 1],
78
+ [3, 2],
79
+ [3, 3],
80
+ [3, 4],
81
+ [3, 5]
82
+ ]
83
+ ],
84
+ [
85
+ [1],
86
+ [
87
+ [0, 1],
88
+ [0, 2],
89
+ [0, 3],
90
+ [3, 3]
91
+ ]
92
+ ]
117
93
  ]
118
- ]
119
- ]
120
- };
94
+ }
121
95
 
122
- const expectedEmptyHeadersLayout1 = {
123
- truncated: true,
124
- headerData: [[]],
125
- sectionsData: [
126
- [
127
- [],
128
- [
129
- [formatLayoutData(0, 0), formatLayoutData(1, 0), formatLayoutData(2, 0)],
130
- [formatLayoutData(0, 0), formatLayoutData(1, 0), formatLayoutData(2, 1)],
131
- [formatLayoutData(0, 0), formatLayoutData(1, 0), formatLayoutData(2, 2)],
132
- [formatLayoutData(0, 0), formatLayoutData(1, 1), formatLayoutData(2, 0)],
133
- [formatLayoutData(0, 0), formatLayoutData(1, 1), formatLayoutData(2, 1)],
134
- [formatLayoutData(0, 0), formatLayoutData(1, 1), formatLayoutData(2, 2)],
135
- [formatLayoutData(0, 0), formatLayoutData(1, 2), formatLayoutData(2, 0)],
136
- [formatLayoutData(0, 0), formatLayoutData(1, 2), formatLayoutData(2, 1)],
137
- [formatLayoutData(0, 0), formatLayoutData(1, 2), formatLayoutData(2, 2)],
138
- [formatLayoutData(0, 1), formatLayoutData(1, 0), formatLayoutData(2, 0)],
139
- [formatLayoutData(0, 1), formatLayoutData(1, 0), formatLayoutData(2, 1)],
140
- [formatLayoutData(0, 1), formatLayoutData(1, 0), formatLayoutData(2, 2)],
141
- [formatLayoutData(0, 1), formatLayoutData(1, 1), formatLayoutData(2, 0)],
142
- [formatLayoutData(0, 1), formatLayoutData(1, 1), formatLayoutData(2, 1)],
143
- [formatLayoutData(0, 1), formatLayoutData(1, 1), formatLayoutData(2, 2)],
144
- [formatLayoutData(0, 1), formatLayoutData(1, 2), formatLayoutData(2, 0)],
145
- [formatLayoutData(0, 1), formatLayoutData(1, 2), formatLayoutData(2, 1)],
146
- [formatLayoutData(0, 1), formatLayoutData(1, 2), formatLayoutData(2, 2)],
147
- [formatLayoutData(0, 2), formatLayoutData(1, 0), formatLayoutData(2, 0)],
148
- [formatLayoutData(0, 2), formatLayoutData(1, 0), formatLayoutData(2, 1)],
96
+ const expected = {
97
+ truncated: false,
98
+ headerData: [
99
+ [{ dimension: { id: 'd0' }, value: { id: '0v0' } }],
100
+ [{ dimension: { id: 'd0' }, value: { id: '0v1' } }],
149
101
  ],
150
- ]
151
- ]
152
- };
153
-
154
- const expectedEmptyRowsLayoutData = {
155
- truncated: true,
156
- headerData: [
157
- [formatLayoutData(0, 0), formatLayoutData(1, 0), formatLayoutData(2, 0)],
158
- [formatLayoutData(0, 0), formatLayoutData(1, 0), formatLayoutData(2, 1)],
159
- [formatLayoutData(0, 0), formatLayoutData(1, 0), formatLayoutData(2, 2)],
160
- [formatLayoutData(0, 0), formatLayoutData(1, 1), formatLayoutData(2, 0)],
161
- [formatLayoutData(0, 0), formatLayoutData(1, 1), formatLayoutData(2, 1)],
162
- [formatLayoutData(0, 0), formatLayoutData(1, 1), formatLayoutData(2, 2)],
163
- [formatLayoutData(0, 0), formatLayoutData(1, 2), formatLayoutData(2, 0)],
164
- [formatLayoutData(0, 0), formatLayoutData(1, 2), formatLayoutData(2, 1)],
165
- [formatLayoutData(0, 0), formatLayoutData(1, 2), formatLayoutData(2, 2)],
166
- [formatLayoutData(0, 1), formatLayoutData(1, 0), formatLayoutData(2, 0)],
167
- [formatLayoutData(0, 1), formatLayoutData(1, 0), formatLayoutData(2, 1)],
168
- [formatLayoutData(0, 1), formatLayoutData(1, 0), formatLayoutData(2, 2)],
169
- [formatLayoutData(0, 1), formatLayoutData(1, 1), formatLayoutData(2, 0)],
170
- [formatLayoutData(0, 1), formatLayoutData(1, 1), formatLayoutData(2, 1)],
171
- [formatLayoutData(0, 1), formatLayoutData(1, 1), formatLayoutData(2, 2)],
172
- [formatLayoutData(0, 1), formatLayoutData(1, 2), formatLayoutData(2, 0)],
173
- [formatLayoutData(0, 1), formatLayoutData(1, 2), formatLayoutData(2, 1)],
174
- [formatLayoutData(0, 1), formatLayoutData(1, 2), formatLayoutData(2, 2)],
175
- [formatLayoutData(0, 2), formatLayoutData(1, 0), formatLayoutData(2, 0)],
176
- [formatLayoutData(0, 2), formatLayoutData(1, 0), formatLayoutData(2, 1)],
177
- ],
178
- sectionsData: [[[], [[]]]],
179
- };
180
-
181
- const observations1 = {
182
- '0:0:0': [], '0:0:1': [], '0:0:2': [],
183
- '0:1:0': [], '0:1:1': [], '0:1:2': [],
184
- '0:2:0': [], '0:2:1': [], '0:2:2': [],
185
- '1:0:0': [], '1:0:1': [], '1:0:2': [],
186
- '1:1:0': [], '1:1:1': [], '1:1:2': [],
187
- '1:2:0': [], '1:2:1': [], '1:2:2': [],
188
- '2:0:0': [], '2:0:1': [], '2:0:2': [],
189
- '2:1:0': [], '2:1:1': [], '2:1:2': [],
190
- '2:2:0': [], '2:2:1': [], '2:2:2': [],
191
- };
192
-
193
- const partialObservations1 = {
194
- '0:0:0': [], '0:0:1': [], '0:0:2': [],
195
- '0:1:0': [], '0:1:1': [], '0:1:2': [],
196
- '0:2:0': [], '0:2:1': [], '0:2:2': [],
197
- '1:2:0': [], '1:2:1': [], '1:2:2': [],
198
- '2:0:0': [], '2:0:1': [], '2:0:2': [],
199
- '2:1:0': [], '2:1:1': [], '2:1:2': [],
200
- '2:2:0': [], '2:2:1': [], '2:2:2': [],
201
- };
202
-
203
- const partialObservations2 = {
204
- '0:0:0': [],
205
- '0:1:0': [],
206
- '0:2:0': [],
207
- '1:0:0': [],
208
- '1:1:0': [],
209
- '1:2:0': [],
210
- '2:0:0': [], '2:0:1': [], '2:0:2': [],
211
- '2:1:0': [], '2:1:1': [], '2:1:2': [],
212
- '2:2:0': [], '2:2:1': [], '2:2:2': [],
213
- };
214
-
215
- const mixedDimensionOrderHeader = {
216
- header: [
217
- { __index: 2, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] },
218
- { __index: 0, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] },
219
- ],
220
- sections: [],
221
- rows: [{ __index: 1, values: [{ __index: 0, __indexPosition: 0 }, { __index: 1, __indexPosition: 1 }, { __index: 2, __indexPosition: 2 }] }],
222
- };
223
-
224
- const expectedRefinedAfterEmptyRowsClean2 = {
225
- truncated: true,
226
- headerData: [
227
- [formatLayoutData(2, 0), formatLayoutData(0, 0)],
228
- [formatLayoutData(2, 0), formatLayoutData(0, 1)],
229
- [formatLayoutData(2, 0), formatLayoutData(0, 2)],
230
- [formatLayoutData(2, 1), formatLayoutData(0, 0)],
231
- [formatLayoutData(2, 1), formatLayoutData(0, 1)],
232
- [formatLayoutData(2, 1), formatLayoutData(0, 2)],
233
- ],
234
- sectionsData: [
235
- [
236
- [],
237
- [
238
- [formatLayoutData(1, 1)],
102
+ sectionsData: [
103
+ [
104
+ [{ dimension: { id: 'd1' }, value: { id: '1v0' } }],
105
+ [
106
+ [
107
+ { dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
108
+ { dimension: { id: 'd3' }, value: { id: '3v0', name: '3V0' } }
109
+ ],
110
+ [
111
+ { dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
112
+ { dimension: { id: 'd3' }, value: { id: '3v0.0', name: '3V0.0', parents: ['3v0'] } }
113
+ ],
114
+ [
115
+ { dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
116
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] } }
117
+ ],
118
+ [
119
+ { dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
120
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] } }
121
+ ],
122
+ [
123
+ { dimension: { id: 'd2' }, value: { id: '2v0.0', name: '2V0.0', parents: ['2v0'] } },
124
+ { dimension: { id: 'd3' }, value: { id: '3v0', name: '3V0' } }
125
+ ],
126
+ [
127
+ { dimension: { id: 'd2' }, value: { id: '2v0.0', name: '2V0.0', parents: ['2v0'] } },
128
+ { dimension: { id: 'd3' }, value: { id: '3v0.0', name: '3V0.0', parents: ['3v0'] } }
129
+ ],
130
+ [
131
+ { dimension: { id: 'd2' }, value: { id: '2v0.0', name: '2V0.0', parents: ['2v0'] } },
132
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] } }
133
+ ],
134
+ [
135
+ { dimension: { id: 'd2' }, value: { id: '2v0.0', name: '2V0.0', parents: ['2v0'] } },
136
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] } }
137
+ ],
138
+ [
139
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.0', name: '2V0.0.0', parents: ['2v0', '2v0.0'] } },
140
+ { dimension: { id: 'd3' }, value: { id: '3v0', name: '3V0' } }
141
+ ],
142
+ [
143
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.0', name: '2V0.0.0', parents: ['2v0', '2v0.0'] } },
144
+ { dimension: { id: 'd3' }, value: { id: '3v0.0', name: '3V0.0', parents: ['3v0'] } }
145
+ ],
146
+ [
147
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.0', name: '2V0.0.0', parents: ['2v0', '2v0.0'] } },
148
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] } }
149
+ ],
150
+ [
151
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.0', name: '2V0.0.0', parents: ['2v0', '2v0.0'] } },
152
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] } }
153
+ ],
154
+ [
155
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
156
+ { dimension: { id: 'd3' }, value: { id: '3v0', name: '3V0' } }
157
+ ],
158
+ [
159
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
160
+ { dimension: { id: 'd3' }, value: { id: '3v0.0', name: '3V0.0', parents: ['3v0'] } }
161
+ ],
162
+ [
163
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
164
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] } }
165
+ ],
166
+ [
167
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
168
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] } }
169
+ ],
170
+ [
171
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
172
+ { dimension: { id: 'd3' }, value: { id: '3v0.1', name: '3V0.1', parents: ['3v0'] } }
173
+ ],
174
+ [
175
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
176
+ { dimension: { id: 'd3' }, value: { id: '3v0.1.0', name: '3V0.1.0', parents: ['3v0', '3v0.1'] } }
177
+ ]
178
+ ]
179
+ ],
180
+ [
181
+ [{ dimension: { id: 'd1' }, value: { id: '1v1' } }],
182
+ [
183
+ [
184
+ { dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
185
+ { dimension: { id: 'd3' }, value: { id: '3v0.0', name: '3V0 > 3V0.0', parents: [] } }
186
+ ],
187
+ [
188
+ { dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
189
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0.0'] } }
190
+ ],
191
+ [
192
+ { dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
193
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0.0'] } }
194
+ ],
195
+ [
196
+ { dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0 > 2V0.0.1', parents: ['2v0'] } },
197
+ { dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0 > 3V0.0 > 3V0.0.1', parents: [] } }
198
+ ]
199
+ ]
200
+ ]
239
201
  ]
240
- ]
241
- ]
242
- };
243
-
244
- const partialObservations3 = {
245
- '0:0:2': [],
246
- '0:1:0': [], '0:1:1': [], '0:1:2': [],
247
- '0:2:2': [],
248
- '1:0:2': [],
249
- '1:1:0': [], '1:1:1': [], '1:1:2': [],
250
- '1:2:2': [],
251
- '2:0:2': [],
252
- '2:1:0': [], '2:1:1': [], '2:1:2': [],
253
- '2:2:2': [],
254
- };
202
+ }
255
203
 
256
- describe('getLayoutData tests', () => {
257
- it('no changes under limit', () => {
258
- expect(
259
- getLayoutData({
260
- layout: simpleLayout,
261
- observations: observations1,
262
- limit: 60,
263
- })
264
- ).to.deep.equal(expectedSimpleLayoutData);
265
- });
266
- it('no headers', () => {
267
- expect(
268
- getLayoutData({
269
- layout: emptyHeadersLayout1,
270
- observations: observations1,
271
- limit: 105
272
- })
273
- ).to.deep.equal(expectedEmptyHeadersLayout1);
274
- });
275
- it('no rows', () => {
276
- expect(
277
- getLayoutData({
278
- layout: emptyRowsLayout,
279
- observations: observations1,
280
- limit: 105
281
- })
282
- ).to.deep.equal(expectedEmptyRowsLayoutData);
283
- });
284
- it('some empty headers to clean after cut', () => {
285
- expect(
286
- getLayoutData({
287
- layout: simpleLayout,
288
- observations: partialObservations1,
289
- limit: 45,
290
- })
291
- ).to.deep.equal(expectedRefinedAfterEmptyHeaderClean);
292
- });
293
- it('multiple empty rows to clean after cut', () => {
294
- expect(
295
- getLayoutData({
296
- layout: noSectionsLayout,
297
- observations: partialObservations2,
298
- limit: 50,
299
- })
300
- ).to.deep.equal(expectedRefinedAfterEmptyRowsClean);
301
- });
302
- it('multiple empty rows to clean after cut with mixed dimensions order in header', () => {
303
- expect(
304
- getLayoutData({
305
- layout: mixedDimensionOrderHeader,
306
- observations: partialObservations3,
307
- limit: 50,
308
- })
309
- ).to.deep.equal(expectedRefinedAfterEmptyRowsClean2);
204
+ expect(getLayoutData(indexes, layout)).to.deep.equal(expected);
310
205
  });
311
206
  });
@@ -1,6 +1,6 @@
1
1
  import { expect } from 'chai';
2
2
  import { getOneValueDimensions } from '../src/rules/src/table/preparators/getOneValueDimensions';
3
- import { getDisplay } from '../src/rules/src/table/preparators/getDisplay';
3
+ import { getDisplay } from '../src/rules/src/preparators/getDisplay';
4
4
 
5
5
  const noDisplayIndexes = [0, 2, 4];
6
6