@sis-cc/dotstatsuite-components 9.1.3 → 9.2.0
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 +2 -1
- package/package.json +1 -1
- 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 +2 -1
- 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
package/test/getCells.test.js
CHANGED
|
@@ -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
|
});
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getLayoutData } from '../src/rules/src/table/factories/getLayoutData';
|
|
3
|
+
|
|
4
|
+
describe('getLayoutData2 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
|
+
]
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
|
|
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
|
+
]
|
|
51
|
+
},
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const indexes = {
|
|
56
|
+
truncated: false,
|
|
57
|
+
header: [[0], [1]],
|
|
58
|
+
sections: [
|
|
59
|
+
[
|
|
60
|
+
[0],
|
|
61
|
+
[
|
|
62
|
+
[0, 0],
|
|
63
|
+
[0, 1],
|
|
64
|
+
[0, 2],
|
|
65
|
+
[0, 3],
|
|
66
|
+
[1, 0],
|
|
67
|
+
[1, 1],
|
|
68
|
+
[1, 2],
|
|
69
|
+
[1, 3],
|
|
70
|
+
[2, 0],
|
|
71
|
+
[2, 1],
|
|
72
|
+
[2, 2],
|
|
73
|
+
[2, 3],
|
|
74
|
+
[3, 0],
|
|
75
|
+
[3, 1],
|
|
76
|
+
[3, 2],
|
|
77
|
+
[3, 3]
|
|
78
|
+
]
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
[1],
|
|
82
|
+
[
|
|
83
|
+
[0, 1],
|
|
84
|
+
[0, 2],
|
|
85
|
+
[0, 3],
|
|
86
|
+
[3, 3]
|
|
87
|
+
]
|
|
88
|
+
]
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const expected = {
|
|
93
|
+
truncated: false,
|
|
94
|
+
headerData: [
|
|
95
|
+
[{ dimension: { id: 'd0' }, value: { id: '0v0' } }],
|
|
96
|
+
[{ dimension: { id: 'd0' }, value: { id: '0v1' } }],
|
|
97
|
+
],
|
|
98
|
+
sectionsData: [
|
|
99
|
+
[
|
|
100
|
+
[{ dimension: { id: 'd1' }, value: { id: '1v0' } }],
|
|
101
|
+
[
|
|
102
|
+
[
|
|
103
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
|
|
104
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0', name: '3V0' } }
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
|
|
108
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0', name: '3V0.0', parents: ['3v0'] } }
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
|
|
112
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] } }
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
|
|
116
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] } }
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0.0', name: '2V0.0', parents: ['2v0'] } },
|
|
120
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0', name: '3V0' } }
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0.0', name: '2V0.0', parents: ['2v0'] } },
|
|
124
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0', name: '3V0.0', parents: ['3v0'] } }
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0.0', name: '2V0.0', parents: ['2v0'] } },
|
|
128
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] } }
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0.0', name: '2V0.0', parents: ['2v0'] } },
|
|
132
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] } }
|
|
133
|
+
],
|
|
134
|
+
[
|
|
135
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0.0.0', name: '2V0.0.0', parents: ['2v0', '2v0.0'] } },
|
|
136
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0', name: '3V0' } }
|
|
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.0', name: '3V0.0', parents: ['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.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] } }
|
|
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.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] } }
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
|
|
152
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0', name: '3V0' } }
|
|
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.0', name: '3V0.0', parents: ['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.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] } }
|
|
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.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] } }
|
|
165
|
+
]
|
|
166
|
+
]
|
|
167
|
+
],
|
|
168
|
+
[
|
|
169
|
+
[{ dimension: { id: 'd1' }, value: { id: '1v1' } }],
|
|
170
|
+
[
|
|
171
|
+
[
|
|
172
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
|
|
173
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0', name: '3V0 > 3V0.0', parents: [] } }
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
|
|
177
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0.0'] } }
|
|
178
|
+
],
|
|
179
|
+
[
|
|
180
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0', name: '2V0' } },
|
|
181
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0.0'] } }
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0 > 2V0.0.1', parents: ['2v0'] } },
|
|
185
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0 > 3V0.0 > 3V0.0.1', parents: [] } }
|
|
186
|
+
]
|
|
187
|
+
]
|
|
188
|
+
]
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
expect(getLayoutData(indexes, layout)).to.deep.equal(expected);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
@@ -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/
|
|
3
|
+
import { getDisplay } from '../src/rules/src/preparators/getDisplay';
|
|
4
4
|
|
|
5
5
|
const noDisplayIndexes = [0, 2, 4];
|
|
6
6
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getSortedLayoutIndexes } from '../src/rules/src/table/factories/getSortedLayoutIndexes';
|
|
3
|
+
import * as R from 'ramda';
|
|
4
|
+
|
|
5
|
+
describe('getSortedLayoutData tests', () => {
|
|
6
|
+
it('basic case', () => {
|
|
7
|
+
const layout = {
|
|
8
|
+
header: [{ id: 'd1', __index: 0 }],
|
|
9
|
+
sections: [{ id: 'd2', __index: 1 }],
|
|
10
|
+
rows: [{ id: 'd3', __index: 2 }],
|
|
11
|
+
};
|
|
12
|
+
const observations = {
|
|
13
|
+
'0:0:0': { orderedDimIndexes: [0, 0, 0] },
|
|
14
|
+
'0:0:1': { orderedDimIndexes: [0, 0, 1] },
|
|
15
|
+
'0:1:0': { orderedDimIndexes: [0, 1, 0] },
|
|
16
|
+
'0:1:1': { orderedDimIndexes: [0, 1, 1] },
|
|
17
|
+
'1:0:0': { orderedDimIndexes: [1, 0, 0] },
|
|
18
|
+
'1:0:1': { orderedDimIndexes: [1, 0, 1] },
|
|
19
|
+
'1:1:0': { orderedDimIndexes: [1, 1, 0] },
|
|
20
|
+
'1:1:1': { orderedDimIndexes: [1, 1, 1] },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const layoutIndexes = {
|
|
24
|
+
header: [[0], [1]],
|
|
25
|
+
sections: [
|
|
26
|
+
[[0], [[0], [1]]],
|
|
27
|
+
[[1], [[0], [1]]]
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
expect(getSortedLayoutIndexes(layout, observations)).to.deep.equal(layoutIndexes);
|
|
32
|
+
});
|
|
33
|
+
it('mixed order dimensions test', () => {
|
|
34
|
+
const layout = {
|
|
35
|
+
header: [
|
|
36
|
+
{ id: 'd3', __index: 2 },
|
|
37
|
+
{ id: 'd1', __index: 0 }
|
|
38
|
+
],
|
|
39
|
+
sections: [],
|
|
40
|
+
rows: [{ id: 'd2', __index: 1 }],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const layoutIndexes = {
|
|
44
|
+
header: [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]],
|
|
45
|
+
sections: [[[], [[0], [1], [2]]]]
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const observations = {
|
|
49
|
+
'0:0:0': { orderedDimIndexes: [0, 0, 0] },
|
|
50
|
+
'0:0:1': { orderedDimIndexes: [0, 0, 1] },
|
|
51
|
+
'0:0:2': { orderedDimIndexes: [0, 0, 2] },
|
|
52
|
+
'0:1:0': { orderedDimIndexes: [0, 1, 0] },
|
|
53
|
+
'0:1:1': { orderedDimIndexes: [0, 1, 1] },
|
|
54
|
+
'0:1:2': { orderedDimIndexes: [0, 1, 2] },
|
|
55
|
+
'0:2:0': { orderedDimIndexes: [0, 2, 0] },
|
|
56
|
+
'0:2:1': { orderedDimIndexes: [0, 2, 1] },
|
|
57
|
+
'0:2:2': { orderedDimIndexes: [0, 2, 2] },
|
|
58
|
+
'1:0:0': { orderedDimIndexes: [1, 0, 0] },
|
|
59
|
+
'1:0:1': { orderedDimIndexes: [1, 0, 1] },
|
|
60
|
+
'1:0:2': { orderedDimIndexes: [1, 0, 2] },
|
|
61
|
+
'1:1:0': { orderedDimIndexes: [1, 1, 0] },
|
|
62
|
+
'1:1:1': { orderedDimIndexes: [1, 1, 1] },
|
|
63
|
+
'1:1:2': { orderedDimIndexes: [1, 1, 2] },
|
|
64
|
+
'1:2:0': { orderedDimIndexes: [1, 2, 0] },
|
|
65
|
+
'1:2:1': { orderedDimIndexes: [1, 2, 1] },
|
|
66
|
+
'1:2:2': { orderedDimIndexes: [1, 2, 2] },
|
|
67
|
+
'2:0:0': { orderedDimIndexes: [2, 0, 0] },
|
|
68
|
+
'2:0:1': { orderedDimIndexes: [2, 0, 1] },
|
|
69
|
+
'2:0:2': { orderedDimIndexes: [2, 0, 2] },
|
|
70
|
+
'2:1:0': { orderedDimIndexes: [2, 1, 0] },
|
|
71
|
+
'2:1:1': { orderedDimIndexes: [2, 1, 1] },
|
|
72
|
+
'2:1:2': { orderedDimIndexes: [2, 1, 2] },
|
|
73
|
+
'2:2:0': { orderedDimIndexes: [2, 2, 0] },
|
|
74
|
+
'2:2:1': { orderedDimIndexes: [2, 2, 1] },
|
|
75
|
+
'2:2:2': { orderedDimIndexes: [2, 2, 2] },
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
expect(getSortedLayoutIndexes(layout, observations)).to.deep.equal(layoutIndexes);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import { getUnitsArtefacts } from '../src/rules/src/table/units/getUnitsArtefacts';
|
|
3
|
-
import { getDisplay } from '../src/rules/src/
|
|
3
|
+
import { getDisplay } from '../src/rules/src/preparators/getDisplay';
|
|
4
4
|
|
|
5
5
|
const noDisplayIndexes = [0, 1];
|
|
6
6
|
const _getDisplay = getDisplay({ noDisplayIndexes });
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getUnitsSeries } from '../src/rules/src/table/units/getUnitsSeries';
|
|
3
|
+
|
|
4
|
+
const observations = {
|
|
5
|
+
0: {
|
|
6
|
+
key: '0:0:0:0',
|
|
7
|
+
units: {
|
|
8
|
+
serieKey: '0:0:x:x',
|
|
9
|
+
A: { value: { index: 0 } },
|
|
10
|
+
B: { value: { index: 0 } },
|
|
11
|
+
C: { value: { index: 0 } }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
1: {
|
|
15
|
+
key: '0:0:1:0',
|
|
16
|
+
units: {
|
|
17
|
+
serieKey: '0:0:x:x',
|
|
18
|
+
A: { value: { index: 0 } },
|
|
19
|
+
B: { value: { index: 0 } },
|
|
20
|
+
C: { value: { index: 1 } }
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
2: {
|
|
24
|
+
key: '1:0:0:0',
|
|
25
|
+
units: {
|
|
26
|
+
serieKey: '1:0:x:x',
|
|
27
|
+
A: { value: { index: 1 } },
|
|
28
|
+
B: { value: { index: 1 } },
|
|
29
|
+
C: { value: { index: 0 } }
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
3: {
|
|
33
|
+
key: '1:0:1:0',
|
|
34
|
+
units: {
|
|
35
|
+
serieKey: '1:0:x:x',
|
|
36
|
+
A: { value: { index: 1 } },
|
|
37
|
+
B: { value: { index: 1 } },
|
|
38
|
+
C: { value: { index: 0 } }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
4: {
|
|
42
|
+
key: '2:0:0:0',
|
|
43
|
+
units: {
|
|
44
|
+
serieKey: '2:0:x:x',
|
|
45
|
+
A: { value: { index: 2 } },
|
|
46
|
+
B: { value: { index: 0 } },
|
|
47
|
+
C: { value: { index: 0 } }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
describe('getUnitsSeries tests', () => {
|
|
53
|
+
it('blank test', () => {
|
|
54
|
+
expect(getUnitsSeries({})).to.deep.equal({});
|
|
55
|
+
});
|
|
56
|
+
it('basic test', () => {
|
|
57
|
+
expect(getUnitsSeries(observations))
|
|
58
|
+
.to.deep.equal({
|
|
59
|
+
'0:0:x:x': { A: { value: { index: 0 } }, B: { value: { index: 0 } }, C: null, serieKey: '0:0:x:x' },
|
|
60
|
+
'1:0:x:x': { A: { value: { index: 1 } }, B: { value: { index: 1 } }, C: { value: { index: 0 } }, serieKey: '1:0:x:x' },
|
|
61
|
+
'2:0:x:x': { A: { value: { index: 2 } }, B: { value: { index: 0 } }, C: { value: { index: 0 } }, serieKey: '2:0:x:x' }
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|