@sis-cc/dotstatsuite-components 9.1.1 → 9.2.1
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/lib/rules/src/preparators/enhanceObservations.js +155 -0
- package/lib/rules/src/preparators/formatValue.js +77 -0
- package/lib/rules/src/preparators/getDimensions.js +55 -0
- package/lib/rules/src/preparators/getDisplay.js +32 -0
- package/lib/rules/src/preparators/getObservations.js +27 -0
- package/lib/rules/src/table/factories/getCells.js +1 -3
- package/lib/rules/src/table/factories/getLayoutData.js +102 -161
- package/lib/rules/src/table/factories/getSortedLayoutIndexes.js +118 -0
- package/lib/rules/src/table/factories/getTableData.js +12 -10
- package/lib/rules/src/table/factories/refineLayoutSize.js +210 -0
- package/lib/rules/src/table/preparators/prepareData.js +23 -23
- package/lib/rules/src/table/units/getAttachmentSeriesIndexes.js +1 -1
- package/lib/rules/src/table/units/getUnitsSeries.js +31 -0
- package/lib/rules/src/v8-transformer.js +3 -2
- package/package.json +2 -2
- package/src/rules/src/preparators/enhanceObservations.js +163 -0
- package/src/rules/src/preparators/formatValue.js +73 -0
- package/src/rules/src/preparators/getDimensions.js +49 -0
- package/src/rules/src/preparators/getDisplay.js +20 -0
- package/src/rules/src/preparators/getObservations.js +19 -0
- package/src/rules/src/table/factories/getCells.js +3 -7
- package/src/rules/src/table/factories/getLayoutData.js +135 -184
- package/src/rules/src/table/factories/getSortedLayoutIndexes.js +108 -0
- package/src/rules/src/table/factories/getTableData.js +10 -10
- package/src/rules/src/table/factories/refineLayoutSize.js +224 -0
- package/src/rules/src/table/preparators/prepareData.js +23 -32
- package/src/rules/src/table/units/getAttachmentSeriesIndexes.js +2 -1
- package/src/rules/src/table/units/getUnitsSeries.js +20 -0
- package/src/rules/src/v8-transformer.js +4 -2
- package/test/appendUnitsInLayoutDataEntry.test.js +3 -3
- package/test/enhanceObservations.test.js +270 -0
- package/test/getAttachmentSeriesIndexes.test.js +1 -1
- package/test/getCells.test.js +4 -39
- package/test/getLayoutData2.test.js +194 -0
- package/test/getOneValueDimensions.test.js +1 -1
- package/test/getSortedLayoutIndexes.test.js +80 -0
- package/test/getUnitsArtefacts.test.js +1 -1
- package/test/getUnitsSeries.test.js +64 -0
- package/test/mocks/table-layout-multi-hierarchies--layout.json +621 -0
- package/test/mocks/table-layout-multi-hierarchies--layoutData.json +32410 -0
- package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +2760 -0
- package/test/mocks/table-layout-multi-hierarchies--observations.json +30688 -0
- package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +2761 -0
- package/test/mocks/table-layout-truncation1--layout.json +27469 -0
- package/test/mocks/table-layout-truncation1--layoutData.json +19413 -0
- package/test/mocks/table-layout-truncation1--layoutIndexes.json +7512 -0
- package/test/mocks/table-layout-truncation1--observations.json +70002 -0
- package/test/mocks/table-layout-truncation1--sizedIndexes.json +3010 -0
- package/test/mocks/table-prep-multi-hierarchies--attributes.json +44 -0
- package/test/mocks/table-prep-multi-hierarchies--dimensions.json +688 -0
- package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +19696 -0
- package/test/mocks/table-prep-multi-hierarchies--observations.json +8246 -0
- package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +2985 -0
- package/test/mocks/table-prep-truncation1--dimensions.json +35057 -0
- package/test/mocks/table-prep-truncation1--enhancedObservations.json +70002 -0
- package/test/mocks/table-prep-truncation1--observations.json +27502 -0
- package/test/mocks/table-prep-truncation1--sdmxJson.json +55103 -0
- package/test/mocks/table-prep-units--observations.json +284286 -0
- package/test/mocks/table-prep-units--unitsSeries.json +41042 -0
- package/test/parseAttributes.test.js +1 -1
- package/test/refineLayoutSize.test.js +415 -0
- package/test/table-layout-perf.test.js +74 -0
- package/test/table-prep-perf.test.js +65 -0
- package/lib/rules/src/table/factories/getSortedLayoutData.js +0 -145
- package/lib/rules/src/table/factories/refineLayoutHierarchy.js +0 -61
- package/lib/rules/src/table/preparators/parseObservations.js +0 -76
- package/lib/rules/src/table/units/getUnitsSeriesOccurences.js +0 -39
- package/src/rules/src/table/factories/getSortedLayoutData.js +0 -133
- package/src/rules/src/table/factories/refineLayoutHierarchy.js +0 -64
- package/src/rules/src/table/preparators/parseObservations.js +0 -81
- package/src/rules/src/table/units/getUnitsSeriesOccurences.js +0 -51
- package/test/appendUnitsInLayoutData.test.js +0 -248
- package/test/getLayoutData.test.js +0 -311
- package/test/getSortedLayoutData.test.js +0 -382
- package/test/getUnitsSeriesOccurences.test.js +0 -133
- package/test/parseObservations.test.js +0 -116
- package/test/refineDimSeriesUnits.test.js +0 -24
- package/test/refineLayoutHierarchy.test.js +0 -79
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { appendUnitsInLayoutData } from '../src/rules/src/table/units/appendUnitsInLayoutData';
|
|
3
|
-
|
|
4
|
-
const headerData = [
|
|
5
|
-
[
|
|
6
|
-
{ dimension: { id: 'H1', __index: 0 }, value: { id: 'H1V1', __index: 0 } },
|
|
7
|
-
{ dimension: { id: 'H2', __index: 2 }, value: { id: 'H2V1', __index: 0 } },
|
|
8
|
-
],[
|
|
9
|
-
{ dimension: { id: 'H1', __index: 0 }, value: { id: 'H1V2', __index: 1 } },
|
|
10
|
-
{ dimension: { id: 'H2', __index: 2 }, value: { id: 'H2V2', __index: 1 } }
|
|
11
|
-
],
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
const sectionsData = [
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
{ dimension: { id: 'S1', __index: 1 }, value: { id: 'S1V1', __index: 0 } },
|
|
18
|
-
{ dimension: { id: 'S2', __index: 3 }, value: { id: 'S2V1', __index: 0 } },
|
|
19
|
-
],
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 0 } },
|
|
23
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 0 } }
|
|
24
|
-
],
|
|
25
|
-
[
|
|
26
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 1 } },
|
|
27
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 1 } }
|
|
28
|
-
]
|
|
29
|
-
]
|
|
30
|
-
],
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
{ dimension: { id: 'S1', __index: 1 }, value: { id: 'S1V1', __index: 1 } },
|
|
34
|
-
{ dimension: { id: 'S2', __index: 3 }, value: { id: 'S2V1', __index: 1 } },
|
|
35
|
-
],
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 0 } },
|
|
39
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 0 } }
|
|
40
|
-
],
|
|
41
|
-
[
|
|
42
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 1 } },
|
|
43
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 1 } }
|
|
44
|
-
]
|
|
45
|
-
]
|
|
46
|
-
],
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
const unitsSeries = {
|
|
50
|
-
"0:x:0:x:x:x": { U1: { id: 'U1', value: { id: 'U1V1' } } },
|
|
51
|
-
"1:x:1:x:x:x": { U1: { id: 'U1', value: { id: 'U1V2' } } },
|
|
52
|
-
"x:0:x:0:x:x": { U2: { id: 'U2', value: { id: 'U2V1' } } },
|
|
53
|
-
"x:1:x:1:x:x": { U2: { id: 'U2', value: { id: 'U2V2' } } },
|
|
54
|
-
"x:x:x:x:0:0": { U3: { id: 'U3', value: { id: 'U3V1' } } },
|
|
55
|
-
"x:x:x:x:1:1": { U3: { id: 'U3', value: { id: 'U3V2' } } },
|
|
56
|
-
"x:0:x:x:0:0": { U4: { id: 'U4', value: { id: 'U4V1' } } },
|
|
57
|
-
"x:1:x:x:1:1": { U4: { id: 'U4', value: { id: 'U4V2' } } }
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
describe('appendUnitsInLayoutData tests', () => {
|
|
61
|
-
it('blank test', () => {
|
|
62
|
-
expect(appendUnitsInLayoutData({
|
|
63
|
-
display: 'label',
|
|
64
|
-
unitDimension: {},
|
|
65
|
-
unitsDisplay: 'header',
|
|
66
|
-
unitsSeries: {},
|
|
67
|
-
unitsDefinitionCodes: [],
|
|
68
|
-
unitsIndexes: {}, // { header: [], sections: [], rows: [] }
|
|
69
|
-
partialUnitSerieIndexes: [],
|
|
70
|
-
layoutIds: {}
|
|
71
|
-
})({})).to.deep.equal({});
|
|
72
|
-
});
|
|
73
|
-
it('header test', () => {
|
|
74
|
-
expect(appendUnitsInLayoutData({
|
|
75
|
-
display: 'code',
|
|
76
|
-
unitDimension: { id: 'U' },
|
|
77
|
-
unitsDisplay: 'header',
|
|
78
|
-
unitsSeries,
|
|
79
|
-
unitsDefinitionCodes: ['U1'],
|
|
80
|
-
unitsIndexes: { header: [0, 1] }, // { header: [], sections: [], rows: [] }
|
|
81
|
-
partialUnitSerieIndexes: ['x', 'x', 'x', 'x', 'x', 'x'],
|
|
82
|
-
layoutIds: {}
|
|
83
|
-
})({ headerData })).to.deep.equal({
|
|
84
|
-
headerData: [
|
|
85
|
-
[
|
|
86
|
-
{ dimension: { id: 'H1', __index: 0 }, value: { id: 'H1V1', __index: 0 } },
|
|
87
|
-
{ dimension: { id: 'H2', __index: 2 }, value: { id: 'H2V1', __index: 0 } },
|
|
88
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U1V1' } },
|
|
89
|
-
],[
|
|
90
|
-
{ dimension: { id: 'H1', __index: 0 }, value: { id: 'H1V2', __index: 1 } },
|
|
91
|
-
{ dimension: { id: 'H2', __index: 2 }, value: { id: 'H2V2', __index: 1 } },
|
|
92
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U1V2' } },
|
|
93
|
-
],
|
|
94
|
-
]
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
it('sections test', () => {
|
|
98
|
-
expect(appendUnitsInLayoutData({
|
|
99
|
-
display: 'code',
|
|
100
|
-
unitDimension: { id: 'U' },
|
|
101
|
-
unitsDisplay: 'sections',
|
|
102
|
-
unitsSeries,
|
|
103
|
-
unitsDefinitionCodes: ['U2'],
|
|
104
|
-
unitsIndexes: { sections: [0, 1] }, // { header: [], sections: [], rows: [] }
|
|
105
|
-
partialUnitSerieIndexes: ['x', 'x', 'x', 'x', 'x', 'x'],
|
|
106
|
-
layoutIds: {},
|
|
107
|
-
})({ sectionsData })).to.deep.equal({
|
|
108
|
-
sectionsData: [
|
|
109
|
-
[
|
|
110
|
-
[
|
|
111
|
-
{ dimension: { id: 'S1', __index: 1 }, value: { id: 'S1V1', __index: 0 } },
|
|
112
|
-
{ dimension: { id: 'S2', __index: 3 }, value: { id: 'S2V1', __index: 0 } },
|
|
113
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U2V1' } },
|
|
114
|
-
],
|
|
115
|
-
[
|
|
116
|
-
[
|
|
117
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 0 } },
|
|
118
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 0 } }
|
|
119
|
-
],
|
|
120
|
-
[
|
|
121
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 1 } },
|
|
122
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 1 } }
|
|
123
|
-
]
|
|
124
|
-
]
|
|
125
|
-
],
|
|
126
|
-
[
|
|
127
|
-
[
|
|
128
|
-
{ dimension: { id: 'S1', __index: 1 }, value: { id: 'S1V1', __index: 1 } },
|
|
129
|
-
{ dimension: { id: 'S2', __index: 3 }, value: { id: 'S2V1', __index: 1 } },
|
|
130
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U2V2' } },
|
|
131
|
-
],
|
|
132
|
-
[
|
|
133
|
-
[
|
|
134
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 0 } },
|
|
135
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 0 } }
|
|
136
|
-
],
|
|
137
|
-
[
|
|
138
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 1 } },
|
|
139
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 1 } }
|
|
140
|
-
]
|
|
141
|
-
]
|
|
142
|
-
],
|
|
143
|
-
]
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
it('rows test', () => {
|
|
147
|
-
expect(appendUnitsInLayoutData({
|
|
148
|
-
display: 'code',
|
|
149
|
-
unitDimension: { id: 'U' },
|
|
150
|
-
unitsDisplay: 'rows',
|
|
151
|
-
unitsSeries,
|
|
152
|
-
unitsDefinitionCodes: ['U3'],
|
|
153
|
-
unitsIndexes: { rows: [0, 1], sections: [] }, // { header: [], sections: [], rows: [] }
|
|
154
|
-
partialUnitSerieIndexes: ['x', 'x', 'x', 'x', 'x', 'x'],
|
|
155
|
-
layoutIds: { sections: ['S1', 'S2'] }
|
|
156
|
-
})({ sectionsData })).to.deep.equal({
|
|
157
|
-
sectionsData: [
|
|
158
|
-
[
|
|
159
|
-
[
|
|
160
|
-
{ dimension: { id: 'S1', __index: 1 }, value: { id: 'S1V1', __index: 0 } },
|
|
161
|
-
{ dimension: { id: 'S2', __index: 3 }, value: { id: 'S2V1', __index: 0 } }
|
|
162
|
-
],
|
|
163
|
-
[
|
|
164
|
-
[
|
|
165
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 0 } },
|
|
166
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 0 } },
|
|
167
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U3V1' } },
|
|
168
|
-
],
|
|
169
|
-
[
|
|
170
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 1 } },
|
|
171
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 1 } },
|
|
172
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U3V2' } },
|
|
173
|
-
]
|
|
174
|
-
]
|
|
175
|
-
],
|
|
176
|
-
[
|
|
177
|
-
[
|
|
178
|
-
{ dimension: { id: 'S1', __index: 1 }, value: { id: 'S1V1', __index: 1 } },
|
|
179
|
-
{ dimension: { id: 'S2', __index: 3 }, value: { id: 'S2V1', __index: 1 } },
|
|
180
|
-
],
|
|
181
|
-
[
|
|
182
|
-
[
|
|
183
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 0 } },
|
|
184
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 0 } },
|
|
185
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U3V1' } },
|
|
186
|
-
],
|
|
187
|
-
[
|
|
188
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 1 } },
|
|
189
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 1 } },
|
|
190
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U3V2' } },
|
|
191
|
-
]
|
|
192
|
-
]
|
|
193
|
-
],
|
|
194
|
-
]
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
it('rows and sections test', () => {
|
|
198
|
-
expect(appendUnitsInLayoutData({
|
|
199
|
-
display: 'code',
|
|
200
|
-
unitDimension: { id: 'U' },
|
|
201
|
-
unitsDisplay: 'rows',
|
|
202
|
-
unitsSeries,
|
|
203
|
-
unitsDefinitionCodes: ['U4'],
|
|
204
|
-
unitsIndexes: { rows: [0, 1], sections: [0] }, // { header: [], sections: [], rows: [] }
|
|
205
|
-
partialUnitSerieIndexes: ['x', 'x', 'x', 'x', 'x', 'x'],
|
|
206
|
-
layoutIds: { sections: ['S1', 'S2'] }
|
|
207
|
-
})({ sectionsData })).to.deep.equal({
|
|
208
|
-
sectionsData: [
|
|
209
|
-
[
|
|
210
|
-
[
|
|
211
|
-
{ dimension: { id: 'S1', __index: 1 }, value: { id: 'S1V1', __index: 0 } },
|
|
212
|
-
{ dimension: { id: 'S2', __index: 3 }, value: { id: 'S2V1', __index: 0 } }
|
|
213
|
-
],
|
|
214
|
-
[
|
|
215
|
-
[
|
|
216
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 0 } },
|
|
217
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 0 } },
|
|
218
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U4V1' } },
|
|
219
|
-
],
|
|
220
|
-
[
|
|
221
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 1 } },
|
|
222
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 1 } },
|
|
223
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: '' } },
|
|
224
|
-
]
|
|
225
|
-
]
|
|
226
|
-
],
|
|
227
|
-
[
|
|
228
|
-
[
|
|
229
|
-
{ dimension: { id: 'S1', __index: 1 }, value: { id: 'S1V1', __index: 1 } },
|
|
230
|
-
{ dimension: { id: 'S2', __index: 3 }, value: { id: 'S2V1', __index: 1 } },
|
|
231
|
-
],
|
|
232
|
-
[
|
|
233
|
-
[
|
|
234
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 0 } },
|
|
235
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 0 } },
|
|
236
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: '' } },
|
|
237
|
-
],
|
|
238
|
-
[
|
|
239
|
-
{ dimension: { id: 'R1', __index: 4 }, value: { id: 'R1V1', __index: 1 } },
|
|
240
|
-
{ dimension: { id: 'R2', __index: 5 }, value: { id: 'R1V1', __index: 1 } },
|
|
241
|
-
{ dimension: { id: 'U' }, value: { id: 'VAL', unitsLabel: 'U4V2' } },
|
|
242
|
-
]
|
|
243
|
-
]
|
|
244
|
-
],
|
|
245
|
-
]
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
});
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { getLayoutData } from '../src/rules/src/table/factories/getLayoutData';
|
|
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)],
|
|
91
|
-
]
|
|
92
|
-
]
|
|
93
|
-
]
|
|
94
|
-
};
|
|
95
|
-
|
|
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)]
|
|
109
|
-
]
|
|
110
|
-
],
|
|
111
|
-
[
|
|
112
|
-
[formatLayoutData(1, 1)],
|
|
113
|
-
[
|
|
114
|
-
[formatLayoutData(2, 0)],
|
|
115
|
-
[formatLayoutData(2, 1)],
|
|
116
|
-
[formatLayoutData(2, 2)]
|
|
117
|
-
]
|
|
118
|
-
]
|
|
119
|
-
]
|
|
120
|
-
};
|
|
121
|
-
|
|
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)],
|
|
149
|
-
],
|
|
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)],
|
|
239
|
-
]
|
|
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
|
-
};
|
|
255
|
-
|
|
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);
|
|
310
|
-
});
|
|
311
|
-
});
|