@sis-cc/dotstatsuite-components 21.0.1 → 21.1.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.
Files changed (234) hide show
  1. package/dist/dotstatsuite-components.js +38112 -0
  2. package/package.json +4 -1
  3. package/.editorconfig +0 -19
  4. package/.gitlab-ci.yml +0 -48
  5. package/prettier.config.js +0 -13
  6. package/src/app.js +0 -13
  7. package/src/bridge-d3-react/README.md +0 -42
  8. package/src/bridge-d3-react/src/app.js +0 -64
  9. package/src/bridge-d3-react/src/index.js +0 -17
  10. package/src/bridge-d3-react/src/mock-choro.js +0 -394
  11. package/src/bridge-d3-react/src/react-chart-factory.js +0 -65
  12. package/src/index.js +0 -12
  13. package/src/rules/README.md +0 -23
  14. package/src/rules/src/chart/getAxisOptions.js +0 -258
  15. package/src/rules/src/chart/getBaseOptions.js +0 -84
  16. package/src/rules/src/chart/getChartOptions.js +0 -118
  17. package/src/rules/src/chart/getGridOptions.js +0 -52
  18. package/src/rules/src/chart/getTooltipOptions.js +0 -230
  19. package/src/rules/src/constants.js +0 -64
  20. package/src/rules/src/date.js +0 -118
  21. package/src/rules/src/dimension-utils.js +0 -54
  22. package/src/rules/src/factories/choro-series.js +0 -65
  23. package/src/rules/src/factories/sample-focus.js +0 -22
  24. package/src/rules/src/factories/sample-series.js +0 -51
  25. package/src/rules/src/factories/scatter-dimension.js +0 -31
  26. package/src/rules/src/factories/scatter-focus.js +0 -39
  27. package/src/rules/src/factories/scatter-series.js +0 -94
  28. package/src/rules/src/factories/stacked-dimension.js +0 -29
  29. package/src/rules/src/factories/stacked-series.js +0 -185
  30. package/src/rules/src/factories/symbol-dimension.js +0 -29
  31. package/src/rules/src/factories/symbol-series.js +0 -62
  32. package/src/rules/src/factories/timeline-focus.js +0 -18
  33. package/src/rules/src/factories/timeline-series.js +0 -91
  34. package/src/rules/src/get-values-enhanced.js +0 -134
  35. package/src/rules/src/header/getDefaultSubtitle.js +0 -40
  36. package/src/rules/src/header/getHeaderUnits.js +0 -17
  37. package/src/rules/src/header/getSubtitleFlags.js +0 -43
  38. package/src/rules/src/header/getTitleFlags.js +0 -8
  39. package/src/rules/src/header/index.js +0 -4
  40. package/src/rules/src/index.js +0 -398
  41. package/src/rules/src/layout.js +0 -113
  42. package/src/rules/src/observation-formater.js +0 -83
  43. package/src/rules/src/preparators/enhanceObservations.js +0 -152
  44. package/src/rules/src/preparators/formatValue.js +0 -84
  45. package/src/rules/src/preparators/getObservations.js +0 -19
  46. package/src/rules/src/preparators/getReportingYearStart.js +0 -16
  47. package/src/rules/src/properties/errors.js +0 -19
  48. package/src/rules/src/properties/focus.js +0 -69
  49. package/src/rules/src/properties/getAvailableChartTypes.js +0 -34
  50. package/src/rules/src/properties/getHeaderProps.js +0 -74
  51. package/src/rules/src/properties/getInformationsStateFromNewProps.js +0 -47
  52. package/src/rules/src/properties/getObservationsType.js +0 -29
  53. package/src/rules/src/properties/getStringifiedSubtitle.js +0 -6
  54. package/src/rules/src/properties/index.js +0 -424
  55. package/src/rules/src/properties/information.js +0 -84
  56. package/src/rules/src/properties/linear.js +0 -129
  57. package/src/rules/src/properties/scatter.js +0 -158
  58. package/src/rules/src/properties/stacked.js +0 -98
  59. package/src/rules/src/properties/symbol.js +0 -79
  60. package/src/rules/src/properties/utils.js +0 -110
  61. package/src/rules/src/sdmx-data/index.js +0 -39
  62. package/src/rules/src/table/factories/getCellValue.js +0 -50
  63. package/src/rules/src/table/index.js +0 -1
  64. package/src/rules/src/v8-transformer.js +0 -176
  65. package/src/rules/test/extractSdmxArtefacts.js +0 -26
  66. package/src/rules/test/get-values-enhanced.test.js +0 -127
  67. package/src/rules/test/oecd-HEALTH_PROT-no-freq.json +0 -2903
  68. package/src/rules/test/oecd-HEALTH_PROT-parsed.js +0 -398
  69. package/src/rules/test/oecd-HEALTH_PROT-wrong-freq.json +0 -2913
  70. package/src/rules/test/oecd-HEALTH_PROT.json +0 -2913
  71. package/src/rules/test/oecd-KEI.json +0 -372
  72. package/src/rules/test/scatter-property.js +0 -455
  73. package/src/rules/test/stacked-property.js +0 -273
  74. package/src/rules/test/symbol-property.js +0 -262
  75. package/src/rules/test/v8-transformer.test.js +0 -90
  76. package/src/rules2/src/applyHierarchicalCodesToDim.js +0 -149
  77. package/src/rules2/src/combinedValuesDisplay.js +0 -74
  78. package/src/rules2/src/constants.js +0 -6
  79. package/src/rules2/src/duplicateObservations.js +0 -35
  80. package/src/rules2/src/enhanceObservations.js +0 -95
  81. package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +0 -29
  82. package/src/rules2/src/getAttributesSeries.js +0 -36
  83. package/src/rules2/src/getCombinationDefinitions.js +0 -47
  84. package/src/rules2/src/getDataflowAttributes.js +0 -23
  85. package/src/rules2/src/getDataflowTooltipAttributesIds.js +0 -31
  86. package/src/rules2/src/getDimensionValuesIndexes.js +0 -13
  87. package/src/rules2/src/getHCodelistsRefsInData.js +0 -32
  88. package/src/rules2/src/getHeaderCombinations.js +0 -48
  89. package/src/rules2/src/getHeaderCoordinates.js +0 -7
  90. package/src/rules2/src/getHeaderSubtitle.js +0 -34
  91. package/src/rules2/src/getHeaderTitle.js +0 -15
  92. package/src/rules2/src/getMSDInformations.js +0 -23
  93. package/src/rules2/src/getManyValuesDimensions.js +0 -34
  94. package/src/rules2/src/getMetadataCoordinates.js +0 -37
  95. package/src/rules2/src/getMetadataStructureFromData.js +0 -17
  96. package/src/rules2/src/getNotDisplayedIds.js +0 -53
  97. package/src/rules2/src/getOneValueDimensions.js +0 -34
  98. package/src/rules2/src/getSeriesCombinations.js +0 -24
  99. package/src/rules2/src/hasCellMetadata.js +0 -14
  100. package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2.js +0 -57
  101. package/src/rules2/src/hierarchiseDimensionWithNativeHierarchy2.js +0 -35
  102. package/src/rules2/src/index.js +0 -50
  103. package/src/rules2/src/parseAttributes.js +0 -41
  104. package/src/rules2/src/parseCombinations.js +0 -102
  105. package/src/rules2/src/parseHierarchicalCodelist.js +0 -48
  106. package/src/rules2/src/parseMetadataSeries.js +0 -117
  107. package/src/rules2/src/prepareData.js +0 -73
  108. package/src/rules2/src/refineAttributes.js +0 -16
  109. package/src/rules2/src/refineDimensions.js +0 -18
  110. package/src/rules2/src/refineMetadataCoordinates.js +0 -28
  111. package/src/rules2/src/refineTimePeriod.js +0 -127
  112. package/src/rules2/src/sdmx3.0DataFormatPatch.js +0 -9
  113. package/src/rules2/src/table/declineObservationsOverAttributes.js +0 -32
  114. package/src/rules2/src/table/getCells.js +0 -93
  115. package/src/rules2/src/table/getCellsAttributesIds.js +0 -38
  116. package/src/rules2/src/table/getCellsMetadataCoordinates.js +0 -13
  117. package/src/rules2/src/table/getCombinationDimensionsData.js +0 -39
  118. package/src/rules2/src/table/getCuratedCells.js +0 -33
  119. package/src/rules2/src/table/getFlagsAndNotes.js +0 -23
  120. package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +0 -16
  121. package/src/rules2/src/table/getLayout.js +0 -84
  122. package/src/rules2/src/table/getLayoutData2.js +0 -198
  123. package/src/rules2/src/table/getSortedLayoutIndexes.js +0 -124
  124. package/src/rules2/src/table/getTableLabelAccessor.js +0 -9
  125. package/src/rules2/src/table/getTableLayoutIds.js +0 -314
  126. package/src/rules2/src/table/getTableProps.js +0 -75
  127. package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +0 -79
  128. package/src/rules2/src/table/parseValueHierarchy.js +0 -33
  129. package/src/rules2/src/table/refineLayoutSize2.js +0 -321
  130. package/src/rules2/src/utils.js +0 -37
  131. package/src/viewer/mocks/bar.js +0 -33
  132. package/src/viewer/mocks/gpp-symbol.js +0 -93
  133. package/src/viewer/mocks/gpp-time.js +0 -1103
  134. package/src/viewer/mocks/row.js +0 -39
  135. package/src/viewer/mocks/scatter.js +0 -93
  136. package/src/viewer/mocks/stack.js +0 -161
  137. package/src/viewer/src/app/leg.js +0 -36
  138. package/src/viewer/src/app/nodata-res.js +0 -22
  139. package/src/viewer/src/app/nodata-sized.js +0 -23
  140. package/src/viewer/src/app/one-table-cell.js +0 -70
  141. package/src/viewer/src/app/table.js +0 -423
  142. package/src/viewer/src/app/use-case-1.js +0 -33
  143. package/src/viewer/src/app/use-case-2.js +0 -38
  144. package/src/viewer/src/app/use-case-3.js +0 -18
  145. package/src/viewer/src/app.js +0 -116
  146. package/src/viewer/src/chart.js +0 -52
  147. package/src/viewer/src/chartUtils/options.js +0 -30
  148. package/src/viewer/src/chartUtils/series.js +0 -51
  149. package/src/viewer/src/footer.js +0 -24
  150. package/src/viewer/src/header.js +0 -10
  151. package/src/viewer/src/index.js +0 -158
  152. package/src/viewer/src/legends/AxisLegend.js +0 -41
  153. package/src/viewer/src/legends/ChartLegends.js +0 -66
  154. package/src/viewer/src/legends/FocusLegend.js +0 -63
  155. package/src/viewer/src/legends/Legend.js +0 -46
  156. package/src/viewer/src/legends/SeriesLegend.js +0 -78
  157. package/src/viewer/src/utils.js +0 -21
  158. package/test/applyHierarchicalCodesToDim.test.js +0 -160
  159. package/test/combinedValuesDisplay.test.js +0 -66
  160. package/test/duplicateObs.test.js +0 -118
  161. package/test/enhanceObservations2.test.js +0 -257
  162. package/test/getAttributesSeries.test.js +0 -66
  163. package/test/getAxisOptions.test.js +0 -309
  164. package/test/getBaseOptions.test.js +0 -77
  165. package/test/getCellValue.test.js +0 -32
  166. package/test/getCells.test.js +0 -178
  167. package/test/getCellsMetadataCoordinates.test.js +0 -40
  168. package/test/getCombinationDefinitions.test.js +0 -104
  169. package/test/getCombinationDimensionsData.test.js +0 -99
  170. package/test/getDataflowAttributes.test.js +0 -23
  171. package/test/getDataflowTooltipAttributesIds.test.js +0 -146
  172. package/test/getDimensionValuesIndexes.test.js +0 -33
  173. package/test/getGridOptions.test.js +0 -65
  174. package/test/getHCodelistsRefs.test.js +0 -23
  175. package/test/getHeaderCombinations.test.js +0 -62
  176. package/test/getHeaderTitle.test.js +0 -25
  177. package/test/getLayout.test.js +0 -54
  178. package/test/getLayoutData2.test.js +0 -535
  179. package/test/getMSDInformations.test.js +0 -35
  180. package/test/getMetadataCoordinates.test.js +0 -0
  181. package/test/getNotDisplayedIds.test.js +0 -47
  182. package/test/getObservationsType.test.js +0 -55
  183. package/test/getOneValueDimensions.test.js +0 -35
  184. package/test/getReportingYearStart.test.js +0 -59
  185. package/test/getSeriesCombinations.test.js +0 -29
  186. package/test/getSortedLayoutIndexes.test.js +0 -1138
  187. package/test/getTableLabelAccessor.test.js +0 -50
  188. package/test/getTableLayoutIds.test.js +0 -356
  189. package/test/hierarchiseDimensionWithNativeHierarchy2.test.js +0 -109
  190. package/test/isTableLayoutCompatible.test.js +0 -102
  191. package/test/metadata-parsing-perf.test.js +0 -509
  192. package/test/mocks/MSD_TEST.json +0 -490
  193. package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +0 -152
  194. package/test/mocks/h-codelist.json +0 -2095
  195. package/test/mocks/large_metadata_series.json +0 -701
  196. package/test/mocks/observations-advanced-attributes.json +0 -55382
  197. package/test/mocks/table-invert-time--data.json +0 -80211
  198. package/test/mocks/table-invert-time--inverted.json +0 -80076
  199. package/test/mocks/table-layout-multi-hierarchies--layout.json +0 -621
  200. package/test/mocks/table-layout-multi-hierarchies--layoutData.json +0 -32411
  201. package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +0 -2760
  202. package/test/mocks/table-layout-multi-hierarchies--observations.json +0 -30688
  203. package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +0 -2762
  204. package/test/mocks/table-layout-truncation1--layout.json +0 -27469
  205. package/test/mocks/table-layout-truncation1--layoutData.json +0 -20358
  206. package/test/mocks/table-layout-truncation1--layoutIndexes.json +0 -7512
  207. package/test/mocks/table-layout-truncation1--observations.json +0 -70002
  208. package/test/mocks/table-layout-truncation1--sizedIndexes.json +0 -3011
  209. package/test/mocks/table-prep-multi-hierarchies--attributes.json +0 -46
  210. package/test/mocks/table-prep-multi-hierarchies--dimensions.json +0 -688
  211. package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +0 -19696
  212. package/test/mocks/table-prep-multi-hierarchies--observations.json +0 -8246
  213. package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +0 -2985
  214. package/test/mocks/table-prep-simple-duplicate--dimensions2.json +0 -858
  215. package/test/mocks/table-prep-simple-duplicate--duplicated2.json +0 -77502
  216. package/test/mocks/table-prep-simple-duplicate--observations2.json +0 -60002
  217. package/test/mocks/table-prep-truncation1--dimensions.json +0 -35057
  218. package/test/mocks/table-prep-truncation1--enhancedObservations.json +0 -70002
  219. package/test/mocks/table-prep-truncation1--observations.json +0 -27502
  220. package/test/mocks/table-prep-truncation1--sdmxJson.json +0 -55103
  221. package/test/mocks/table-prep-units--observations.json +0 -284286
  222. package/test/mocks/table-prep-units--unitsSeries.json +0 -41042
  223. package/test/parseAttributes.test.js +0 -36
  224. package/test/parseCombinations.test.js +0 -172
  225. package/test/parseHierarchicalCodelist.test.js +0 -140
  226. package/test/parseMetadataSeries.test.js +0 -128
  227. package/test/parseSeriesIndexesHierarchies.test.js +0 -345
  228. package/test/parseValueHierarchy.test.js +0 -138
  229. package/test/refineAttributes.test.js +0 -29
  230. package/test/refineLayoutSize2.test.js +0 -3410
  231. package/test/refineMetadataCoordinates.test.js +0 -86
  232. package/test/refineTimePeriod.test.js +0 -580
  233. package/test/refinedDimensions.test.js +0 -35
  234. package/vite.config.mjs +0 -51
@@ -1,273 +0,0 @@
1
- import { expect } from 'chai';
2
- import { BAR, PERCENT, STACKED, VALUES } from '../src/constants';
3
- import {
4
- onChangeStackedDimension,
5
- onChangeStackedMode,
6
- stackedStateFromNewProps
7
- } from '../src/properties/stacked';
8
- import oecd_KEI from './oecd-KEI.json';
9
-
10
- const undefinedState = {
11
- stackedDimension: undefined,
12
- stackedMode: undefined
13
- };
14
-
15
- const defaultState = {
16
- stackedDimension: 'LOCATION',
17
- stackedMode: VALUES,
18
- };
19
-
20
- const stateWithFocus = (state) => ({ ...state, baseline: [], highlight: [] });
21
-
22
- const defaultStateWithFocus = stateWithFocus(defaultState);
23
-
24
- describe('stackedStateFromNewProps tests', () => {
25
- it('undefined state with focus from no data', () => {
26
- const props = { type: STACKED };
27
- const expected = stateWithFocus(undefinedState);
28
- expect(stackedStateFromNewProps(props, defaultState)).to.deep.equal(expected);
29
- });
30
- it('undefined state without focus from non stacked type', () => {
31
- const props = { data: oecd_KEI, type: BAR };
32
- expect(stackedStateFromNewProps(props, defaultState)).to.deep.equal(undefinedState);
33
- });
34
- it('default state from no state', () => {
35
- const props = { data: oecd_KEI, type: STACKED };
36
- expect(stackedStateFromNewProps(props, undefined)).to.deep.equal(defaultStateWithFocus);
37
- });
38
- it('default state from undefined state', () => {
39
- const props = { data: oecd_KEI, type: STACKED };
40
- expect(stackedStateFromNewProps(props, undefinedState)).to.deep.equal(defaultStateWithFocus);
41
- });
42
- it('default state from default state', () => {
43
- const props = { data: oecd_KEI, type: STACKED };
44
- expect(stackedStateFromNewProps(props, defaultState)).to.deep.equal(defaultStateWithFocus);
45
- });
46
- it('default state from non existing mode', () => {
47
- const props = { data: oecd_KEI, type: STACKED };
48
- const state = { stackedDimension: 'LOCATION', stackedMode: 'RANDOM' }
49
- expect(stackedStateFromNewProps(props, state)).to.deep.equal(defaultStateWithFocus);
50
- });
51
- it('correct dimension but non existing mode', () => {
52
- const props = { data: oecd_KEI, type: STACKED };
53
- const state = { stackedDimension: 'SUBJECT', stackedMode: 'RANDOM' }
54
- const expected = stateWithFocus({ stackedDimension: 'SUBJECT', stackedMode: VALUES });
55
- expect(stackedStateFromNewProps(props, state)).to.deep.equal(expected);
56
- });
57
- it('non existing dimension but correct mode', () => {
58
- const props = { data: oecd_KEI, type: STACKED };
59
- const state = { stackedDimension: 'RANDOM', stackedMode: PERCENT }
60
- const expected = stateWithFocus({ stackedDimension: 'LOCATION', stackedMode: PERCENT });
61
- expect(stackedStateFromNewProps(props, state)).to.deep.equal(expected);
62
- });
63
- it('dimension with only one value', () => {
64
- const props = { data: oecd_KEI, type: STACKED };
65
- const state = { stackedDimension: 'MEASURE', stackedMode: VALUES }
66
- expect(stackedStateFromNewProps(props, state)).to.deep.equal(defaultStateWithFocus);
67
- });
68
- });
69
-
70
- describe('focus tests through stackedStateFromNewProps', () => {
71
- it('empty focus', () => {
72
- const props = { data: oecd_KEI, type: STACKED };
73
- const state = { type: STACKED, baseline: [], highlight: [] };
74
- expect(stackedStateFromNewProps(props, state)).to.deep.equal(defaultStateWithFocus);
75
- });
76
- it('correct focus', () => {
77
- const props = { data: oecd_KEI, type: STACKED };
78
- const state = {
79
- baseline: [
80
- {
81
- label: 'France',
82
- value: 'FRA'
83
- }
84
- ],
85
- highlight: [
86
- {
87
- label: 'Australia',
88
- value: 'AUS'
89
- },
90
- {
91
- label: 'Austria',
92
- value: 'AUT'
93
- },
94
- {
95
- label: 'Czech Republic',
96
- value: 'CZE'
97
- }
98
- ]
99
- };
100
- const expected = { ...defaultState, ...state }
101
- expect(stackedStateFromNewProps(props, { ...state, type: STACKED })).to.deep.equal(expected);
102
- });
103
- it('all wrong focus', () => {
104
- const props = { data: oecd_KEI, type: STACKED };
105
- const state = {
106
- type: STACKED,
107
- baseline: [
108
- {
109
- label: 'RANDOM 1',
110
- value: 'RANDOM_VAL1'
111
- }
112
- ],
113
- highlight: [
114
- {
115
- label: 'RANDOM 2',
116
- value: 'RANDOM_VAL2'
117
- },
118
- {
119
- label: 'RANDOM 3',
120
- value: 'RANDOM_VAL3'
121
- },
122
- {
123
- label: 'RANDOM 4',
124
- value: 'RANDOM_VAL4'
125
- }
126
- ]
127
- };
128
- expect(stackedStateFromNewProps(props, state)).to.deep.equal(defaultStateWithFocus);
129
- });
130
- it('mix of correct and wrong', () => {
131
- const props = { data: oecd_KEI, type: STACKED };
132
- const state = {
133
- type: STACKED,
134
- baseline: [
135
- {
136
- label: 'France',
137
- value: 'FRA'
138
- }
139
- ],
140
- highlight: [
141
- {
142
- label: 'RANDOM 2',
143
- value: 'RANDOM_VAL2'
144
- },
145
- {
146
- label: 'Austria',
147
- value: 'AUT'
148
- },
149
- {
150
- label: 'RANDOM 4',
151
- value: 'RANDOM_VAL4'
152
- }
153
- ]
154
- };
155
- const expected = {
156
- baseline: [
157
- {
158
- label: 'France',
159
- value: 'FRA'
160
- }
161
- ],
162
- highlight: [
163
- {
164
- label: 'Austria',
165
- value: 'AUT'
166
- }
167
- ]
168
- };
169
- expect(stackedStateFromNewProps(props, state)).to.deep.equal({ ...defaultState, ...expected });
170
- });
171
- it('code display', () => {
172
- const props = { data: oecd_KEI, type: STACKED, display: 'code' };
173
- const state = {
174
- type: STACKED,
175
- baseline: [
176
- {
177
- label: 'France',
178
- value: 'FRA'
179
- }
180
- ],
181
- highlight: [
182
- {
183
- label: 'Austria',
184
- value: 'AUT'
185
- }
186
- ]
187
- };
188
- const expected = {
189
- ...defaultState,
190
- baseline: [
191
- {
192
- label: 'FRA',
193
- value: 'FRA'
194
- }
195
- ],
196
- highlight: [
197
- {
198
- label: 'AUT',
199
- value: 'AUT'
200
- }
201
- ]
202
- };
203
- expect(stackedStateFromNewProps(props, state)).to.deep.equal(expected);
204
- });
205
- it('both display', () => {
206
- const props = { data: oecd_KEI, type: STACKED, display: 'both' };
207
- const state = {
208
- type: STACKED,
209
- baseline: [
210
- {
211
- label: 'France',
212
- value: 'FRA'
213
- }
214
- ],
215
- highlight: [
216
- {
217
- label: 'Austria',
218
- value: 'AUT'
219
- }
220
- ]
221
- };
222
- const expected = {
223
- ...defaultState,
224
- baseline: [
225
- {
226
- label: '(FRA) France',
227
- value: 'FRA'
228
- }
229
- ],
230
- highlight: [
231
- {
232
- label: '(AUT) Austria',
233
- value: 'AUT'
234
- }
235
- ]
236
- };
237
- expect(stackedStateFromNewProps(props, state)).to.deep.equal(expected);
238
- });
239
- });
240
-
241
- describe('onChangeStackedDimension tests', () => {
242
- it('no data', () => {
243
- expect(onChangeStackedDimension({})('LOCATION')).to.deep.equal({});
244
- });
245
- it('no value', () => {
246
- expect(onChangeStackedDimension({ data: oecd_KEI })(undefined)).to.deep.equal({});
247
- });
248
- it('non existing dimension', () => {
249
- expect(onChangeStackedDimension({ data: oecd_KEI })('RANDOM')).to.deep.equal({});
250
- });
251
- it('correct dimension', () => {
252
- const expected = stateWithFocus({ stackedDimension: 'SUBJECT' });
253
- expect(onChangeStackedDimension({ data: oecd_KEI })('SUBJECT')).to.deep.equal(expected);
254
- });
255
- it('dimension with only one value', () => {
256
- expect(onChangeStackedDimension({ data: oecd_KEI })('MEASURE')).to.deep.equal({});
257
- });
258
- });
259
-
260
- describe('onChangeStackedMode tests', () => {
261
- it('no value', () => {
262
- expect(onChangeStackedMode(undefined)).to.deep.equal({});
263
- });
264
- it('non existing mode', () => {
265
- expect(onChangeStackedMode('random')).to.deep.equal({});
266
- })
267
- it('values', () => {
268
- expect(onChangeStackedMode(VALUES)).to.deep.equal({ stackedMode: VALUES });
269
- });
270
- it('percent', () => {
271
- expect(onChangeStackedMode(PERCENT)).to.deep.equal({ stackedMode: PERCENT });
272
- });
273
- });
@@ -1,262 +0,0 @@
1
- import { expect } from 'chai';
2
- import { BAR, H_SYMBOL } from '../src/constants';
3
- import {
4
- onChangeSymbolDim,
5
- symbolStateFromNewProps
6
- } from '../src/properties/symbol';
7
- import oecd_KEI from './oecd-KEI.json';
8
-
9
- const undefinedState = {
10
- symbolDimension: undefined,
11
- };
12
-
13
- const undefinedStateWithFocus = {
14
- baseline: [],
15
- highlight: [],
16
- symbolDimension: undefined,
17
- };
18
-
19
- describe('symbolStateFromNewProps tests', () => {
20
- it('undefined with focus from no data', () => {
21
- const props = { type: H_SYMBOL };
22
- const state = { symbolDimension: 'SUBJECT' };
23
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(undefinedStateWithFocus);
24
- });
25
- it('undefined without focus from not symbol type', () => {
26
- const props = { data: oecd_KEI, type: BAR };
27
- const state = { symbolDimension: 'SUBJECT' };
28
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(undefinedState);
29
- });
30
- it('default from no state', () => {
31
- const props = { data: oecd_KEI, type: H_SYMBOL};
32
- const expected = { baseline: [], highlight: [], symbolDimension: 'SUBJECT' };
33
- expect(symbolStateFromNewProps(props, undefined)).to.deep.equal(expected);
34
- });
35
- it('default from undefined state', () => {
36
- const props = { data: oecd_KEI, type: H_SYMBOL};
37
- const expected = { baseline: [], highlight: [], symbolDimension: 'SUBJECT' };
38
- expect(symbolStateFromNewProps(props, undefinedState)).to.deep.equal(expected);
39
- });
40
- it('default from default state', () => {
41
- const props = { data: oecd_KEI, type: H_SYMBOL};
42
- const state = { symbolDimension: 'SUBJECT' };
43
- const expected = { baseline: [], highlight: [], symbolDimension: 'SUBJECT' };
44
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(expected);
45
- });
46
- it('default from no existing dimension', () => {
47
- const props = { data: oecd_KEI, type: H_SYMBOL};
48
- const state = { symbolDimension: 'RANDOM' };
49
- const expected = { baseline: [], highlight: [], symbolDimension: 'SUBJECT' };
50
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(expected);
51
- });
52
- it('default from dimension with only one value', () => {
53
- const props = { data: oecd_KEI, type: H_SYMBOL};
54
- const state = { symbolDimension: 'MEASURE' };
55
- const expected = { baseline: [], highlight: [], symbolDimension: 'SUBJECT' };
56
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(expected);
57
- });
58
- it('correct dimension', () => {
59
- const props = { data: oecd_KEI, type: H_SYMBOL};
60
- const state = { symbolDimension: 'LOCATION' };
61
- const expected = { baseline: [], highlight: [], symbolDimension: 'LOCATION' };
62
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(expected);
63
- });
64
- });
65
-
66
- describe('focus tests through symbolStateFromNewProps', () => {
67
- it('empty focus', () => {
68
- const props = { data: oecd_KEI, type: H_SYMBOL };
69
- const state = { type: H_SYMBOL, baseline: [], highlight: [] };
70
- const expected = { baseline: [], highlight: [], symbolDimension: 'SUBJECT' };
71
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(expected);
72
- });
73
- it('correct focus', () => {
74
- const props = { data: oecd_KEI, type: H_SYMBOL };
75
- const state = {
76
- baseline: [
77
- {
78
- label: 'France',
79
- value: 'FRA'
80
- }
81
- ],
82
- highlight: [
83
- {
84
- label: 'Australia',
85
- value: 'AUS'
86
- },
87
- {
88
- label: 'Austria',
89
- value: 'AUT'
90
- },
91
- {
92
- label: 'Czech Republic',
93
- value: 'CZE'
94
- }
95
- ]
96
- };
97
- const expected = { symbolDimension: 'SUBJECT', ...state }
98
- expect(symbolStateFromNewProps(props, { ...state, type: H_SYMBOL })).to.deep.equal(expected);
99
- });
100
- it('all wrong focus', () => {
101
- const props = { data: oecd_KEI, type: H_SYMBOL };
102
- const state = {
103
- type: H_SYMBOL,
104
- baseline: [
105
- {
106
- label: 'RANDOM 1',
107
- value: 'RANDOM_VAL1'
108
- }
109
- ],
110
- highlight: [
111
- {
112
- label: 'RANDOM 2',
113
- value: 'RANDOM_VAL2'
114
- },
115
- {
116
- label: 'RANDOM 3',
117
- value: 'RANDOM_VAL3'
118
- },
119
- {
120
- label: 'RANDOM 4',
121
- value: 'RANDOM_VAL4'
122
- }
123
- ]
124
- };
125
- const expected = { baseline: [], highlight: [], symbolDimension: 'SUBJECT' };
126
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(expected);
127
- });
128
- it('mix of correct and wrong', () => {
129
- const props = { data: oecd_KEI, type: H_SYMBOL };
130
- const state = {
131
- type: H_SYMBOL,
132
- baseline: [
133
- {
134
- label: 'France',
135
- value: 'FRA'
136
- }
137
- ],
138
- highlight: [
139
- {
140
- label: 'RANDOM 2',
141
- value: 'RANDOM_VAL2'
142
- },
143
- {
144
- label: 'Austria',
145
- value: 'AUT'
146
- },
147
- {
148
- label: 'RANDOM 4',
149
- value: 'RANDOM_VAL4'
150
- }
151
- ]
152
- };
153
- const expected = {
154
- baseline: [
155
- {
156
- label: 'France',
157
- value: 'FRA'
158
- }
159
- ],
160
- highlight: [
161
- {
162
- label: 'Austria',
163
- value: 'AUT'
164
- }
165
- ],
166
- symbolDimension: 'SUBJECT'
167
- };
168
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(expected);
169
- });
170
- it('code display', () => {
171
- const props = { data: oecd_KEI, type: H_SYMBOL, display: 'code' };
172
- const state = {
173
- type: H_SYMBOL,
174
- baseline: [
175
- {
176
- label: 'France',
177
- value: 'FRA'
178
- }
179
- ],
180
- highlight: [
181
- {
182
- label: 'Austria',
183
- value: 'AUT'
184
- }
185
- ]
186
- };
187
- const expected = {
188
- baseline: [
189
- {
190
- label: 'FRA',
191
- value: 'FRA'
192
- }
193
- ],
194
- highlight: [
195
- {
196
- label: 'AUT',
197
- value: 'AUT'
198
- }
199
- ],
200
- symbolDimension: 'SUBJECT'
201
- };
202
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(expected);
203
- });
204
- it('both display', () => {
205
- const props = { data: oecd_KEI, type: H_SYMBOL, display: 'both' };
206
- const state = {
207
- type: H_SYMBOL,
208
- baseline: [
209
- {
210
- label: 'France',
211
- value: 'FRA'
212
- }
213
- ],
214
- highlight: [
215
- {
216
- label: 'Austria',
217
- value: 'AUT'
218
- }
219
- ]
220
- };
221
- const expected = {
222
- baseline: [
223
- {
224
- label: '(FRA) France',
225
- value: 'FRA'
226
- }
227
- ],
228
- highlight: [
229
- {
230
- label: '(AUT) Austria',
231
- value: 'AUT'
232
- }
233
- ],
234
- symbolDimension: 'SUBJECT'
235
- };
236
- expect(symbolStateFromNewProps(props, state)).to.deep.equal(expected);
237
- });
238
- });
239
-
240
- describe('onChangeSymbolDim tests', () => {
241
- it('no data', () => {
242
- const props = { type: H_SYMBOL };
243
- expect(onChangeSymbolDim(props)('LOCATION')).to.deep.equal({});
244
- });
245
- it('no selection', () => {
246
- const props = { data: oecd_KEI, type: H_SYMBOL };
247
- expect(onChangeSymbolDim(props)(undefined)).to.deep.equal({});
248
- });
249
- it('valid dimension within dataset', () => {
250
- const props = { data: oecd_KEI, type: H_SYMBOL };
251
- const expected = { baseline: [], highlight: [], symbolDimension: 'LOCATION' };
252
- expect(onChangeSymbolDim(props)('LOCATION')).to.deep.equal(expected);
253
- });
254
- it('non valid dimension', () => {
255
- const props = { data: oecd_KEI, type: H_SYMBOL };
256
- expect(onChangeSymbolDim(props)('RANDOM')).to.deep.equal({});
257
- });
258
- it('dimension with only one value', () => {
259
- const props = { data: oecd_KEI, type: H_SYMBOL };
260
- expect(onChangeSymbolDim(props)('MEASURE')).to.deep.equal({});
261
- })
262
- });
@@ -1,90 +0,0 @@
1
- import * as V8 from '../sdmx-data';
2
-
3
- describe('rules - sdmx-data', () => {
4
- describe('setAnnotationsLayout', () => {
5
- const layout1 = {};
6
- test('annotations is row', () => {
7
- expect(V8.setAnnotationsLayout('ID', layout1)([{ type: V8.LAYOUT_ROW }])).toEqual({ rows: ['ID'] });
8
- });
9
- test('annotations is header', () => {
10
- expect(V8.setAnnotationsLayout('ID', layout1)([{ type: V8.LAYOUT_COLUMN }, {type: 'truc'}, {type: 'truc'}])).toEqual({ header: ['ID'] });
11
- });
12
- test('annotations is sections', () => {
13
- expect(V8.setAnnotationsLayout('ID', layout1)([{type: 'truc'}, {type: 'truc'}, { type: V8.LAYOUT_ROW_SECTION }])).toEqual({ sections: ['ID'] });
14
- });
15
- test('annotations is undefined - should be return layout', () => {
16
- expect(V8.setAnnotationsLayout('ID', layout1)([undefined])).toEqual({});
17
- });
18
- test('ids should be ["ID1","ID2","ID3"]', () => {
19
- expect(V8.setAnnotationsLayout('ID1,ID2,ID3', layout1)([{ type: V8.LAYOUT_ROW_SECTION }])).toEqual({ sections: ['ID1','ID2','ID3'] });
20
- });
21
- test('id is undefined - should be return layout', () => {
22
- const layout2 = { header: ['id'] };
23
- expect(V8.setAnnotationsLayout(undefined, layout2)([{ type: V8.LAYOUT_ROW_SECTION }])).toEqual({ header: ['id'], sections: ['']});
24
- });
25
- });
26
- describe('getIsHidden', () => {
27
- test('return isHidden', () => {
28
- const annotations = [
29
- {"type": "NOT_DISPLAYED", "texts": { "en": "Dimension to be shown in row section - full description" }},
30
- {"type": "ORDER", "texts": { "en": "5" }},
31
- {"type": "FULL_NAME","texts": { "en": "Dimension to be shown in row section - full last"}},
32
- ];
33
- expect(V8.getIsHidden(annotations)).toEqual({ isHidden: true});
34
- });
35
- test('return empty string', () => {
36
- const annotations = [{"type": "ORDER", "texts": { "en": "5" }}];
37
- expect(V8.getIsHidden(annotations)).toEqual({});
38
- });
39
- });
40
- describe('setIndexPositions', () => {
41
- const annotations = [
42
- {type: 0},
43
- {type: 1},
44
- {type: 2},
45
- {type: 3 },
46
- {type: "ORDER", text: "5"},
47
- {type: "ORDER"},
48
- {type: 6},
49
- {type: 7},
50
- {type: 8}
51
- ];
52
- test('has no result', () => {
53
- const dimObservationAnnotations = [0,1];
54
- expect(V8.setIndexPositions('en')([])).toEqual({});
55
- });
56
- test('__indexPosition 5', () => {
57
- const dimObservationAnnotations = [4];
58
- expect(V8.setIndexPositions('en')([{type: "ORDER", texts: { "en": "5" }}] )).toEqual({ __indexPosition: 5});
59
- });
60
- test('__indexPosition null', () => {
61
- const dimObservationAnnotations = [5];
62
- expect(V8.setIndexPositions('en')([{type: "ORDER"}])).toEqual({ __indexPosition: null});
63
- });
64
- });
65
- describe('getRelationnalAnnotations', () => {
66
- const annotations = [{type: 0},{type: 1},{type: 2},{type: 3},{type: 4},{type: 5},{type: 6},{type: 7},{type: 8}];
67
- const dimAnnotations = [2,3,5,8];
68
-
69
- test('get the true indexes ', () => {
70
- expect(V8.getRelationnalAnnotations(dimAnnotations)(annotations)).toEqual([{type: 2},{type: 3},{type: 5},{type: 8}]);
71
- });
72
- test('annotations is empty', () => {
73
- expect(V8.getRelationnalAnnotations(dimAnnotations)([])).toEqual([{}, {}, {}, {}]);
74
- });
75
- test('dimAnnotations is empty', () => {
76
- expect(V8.getRelationnalAnnotations([])(annotations)).toEqual([]);
77
- });
78
- });
79
- describe('getPriorityIndexPosition', () => {
80
- test('__indexPosition isNil expected order value', () => {
81
- expect(V8.getPriorityIndexPosition(50)({ __indexPosition: undefined })).toEqual({ __indexPosition: 50 });
82
- });
83
- test('__indexPosition 5 expected __indexPosition', () => {
84
- expect(V8.getPriorityIndexPosition(50)({ __indexPosition: 5 })).toEqual({ __indexPosition: 5 });
85
- });
86
- test('__indexPosition isNil and order too expected null', () => {
87
- expect(V8.getPriorityIndexPosition(null)({ __indexPosition: undefined })).toEqual({ __indexPosition: null });
88
- });
89
- });
90
- });