@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,455 +0,0 @@
1
- import { expect } from 'chai';
2
- import { SCATTER, BAR } from '../src/constants';
3
- import oecd_KEI from './oecd-KEI.json';
4
- import {
5
- scatterStateFromNewProps,
6
- scatterStateValueToOption,
7
- scatterValueOptions,
8
- onChangeScatterDim,
9
- onChangeScatterVal,
10
- } from '../src/properties/scatter';
11
-
12
- const undefinedState = {
13
- scatterDimension: undefined,
14
- scatterX: undefined,
15
- scatterY: undefined,
16
- };
17
-
18
- const scatterKEIDefaultState = {
19
- scatterDimension: 'SUBJECT',
20
- scatterX: 'PRINTO01',
21
- scatterY: 'PRMNTO01',
22
- };
23
-
24
- const scatterKEICustomState = {
25
- scatterDimension: 'LOCATION',
26
- scatterX: 'AUS',
27
- scatterY: 'AUT',
28
- };
29
-
30
- const scatterKEICustomState2 = {
31
- scatterDimension: 'LOCATION',
32
- scatterX: 'CZE',
33
- scatterY: 'FRA',
34
- };
35
-
36
- const scatterKEICustomStateWithoutValues = {
37
- scatterDimension: 'LOCATION',
38
- scatterX: undefined,
39
- scatterY: undefined,
40
- };
41
-
42
- const scatterKEICustomStateWithoutDim = {
43
- scatterDimension: undefined,
44
- scatterX: 'AUS',
45
- scatterY: 'AUT',
46
- };
47
-
48
- const scatterUnexistingState = {
49
- scatterDimension: 'undefined_dim',
50
- scatterX: 'undefined_val1',
51
- scatterY: 'undefined_val2'
52
- };
53
-
54
- // focus tested separately
55
- const stateWithFocus = (state) => ({ ...state, highlight: [], baseline: [] });
56
-
57
- const undefinedStateWithFocus = stateWithFocus(undefinedState);
58
-
59
- const defaultKEIState = stateWithFocus(scatterKEIDefaultState);
60
-
61
- const customKEIState = stateWithFocus(scatterKEICustomState);
62
-
63
- const customKEIState2 = stateWithFocus(scatterKEICustomState2);
64
-
65
- describe('scatterStateFromNewProps tests', () => {
66
- it('undefined state from no data', () => {
67
- const props = { type: SCATTER };
68
- expect(scatterStateFromNewProps(props, scatterKEIDefaultState)).to.deep.equal(undefinedStateWithFocus);
69
- });
70
- it('undefined state from not scatter type', () => {
71
- const props = { data: oecd_KEI, type: BAR };
72
- expect(scatterStateFromNewProps(props, scatterKEIDefaultState)).to.deep.equal(undefinedState);
73
- });
74
- it('default from no state', () => {
75
- const props = { data: oecd_KEI, type: SCATTER};
76
- expect(scatterStateFromNewProps(props, {})).to.deep.equal(defaultKEIState);
77
- });
78
- it('default from undefined state', () => {
79
- const props = { data: oecd_KEI, type: SCATTER };
80
- expect(scatterStateFromNewProps(props, undefinedState)).to.deep.equal(defaultKEIState);
81
- });
82
- it('default from unexisting state', () => {
83
- const props = { data: oecd_KEI, type: SCATTER };
84
- expect(scatterStateFromNewProps(props, scatterUnexistingState)).to.deep.equal(defaultKEIState);
85
- });
86
- it('default from default state', () => {
87
- const props = { data: oecd_KEI, type: SCATTER };
88
- expect(scatterStateFromNewProps(props, scatterKEIDefaultState)).to.deep.equal(defaultKEIState);
89
- });
90
- it('custom state from custom state', () => {
91
- const props = { data: oecd_KEI, type: SCATTER };
92
- expect(scatterStateFromNewProps(props, scatterKEICustomState)).to.deep.equal(customKEIState);
93
- });
94
- it('custom state without values', () => {
95
- const props = { data: oecd_KEI, type: SCATTER };
96
- expect(scatterStateFromNewProps(props, scatterKEICustomStateWithoutValues)).to.deep.equal(customKEIState)
97
- });
98
- it('default state from custom without dimension', () => {
99
- const props = { data: oecd_KEI, type: SCATTER };
100
- expect(scatterStateFromNewProps(props, scatterKEICustomStateWithoutDim)).to.deep.equal(defaultKEIState)
101
- });
102
- });
103
-
104
- describe('focus tests through scatterStateFromNewProps', () => {
105
- it('empty focus', () => {
106
- const props = { data: oecd_KEI, type: SCATTER };
107
- const state = { type: SCATTER, baseline: [], highlight: [] };
108
- expect(scatterStateFromNewProps(props, state)).to.deep.equal(defaultKEIState);
109
- });
110
- it('correct focus', () => {
111
- const props = { data: oecd_KEI, type: SCATTER };
112
- const state = {
113
- baseline: [
114
- {
115
- label: 'Country - France',
116
- value: { dimensionId: 'LOCATION', dimensionValueId: 'FRA' }
117
- }
118
- ],
119
- highlight: [
120
- {
121
- label: 'Country - Australia',
122
- value: { dimensionId: 'LOCATION', dimensionValueId: 'AUS' }
123
- },
124
- {
125
- label: 'Country - Austria',
126
- value: { dimensionId: 'LOCATION', dimensionValueId: 'AUT' }
127
- },
128
- {
129
- label: 'Country - Czech Republic',
130
- value: { dimensionId: 'LOCATION', dimensionValueId: 'CZE' }
131
- }
132
- ]
133
- };
134
- expect(scatterStateFromNewProps(props, { ...state, type: SCATTER })).to.deep.equal({ ...defaultKEIState, ...state });
135
- });
136
- it('all wrong focus', () => {
137
- const props = { data: oecd_KEI, type: SCATTER };
138
- const state = {
139
- baseline: [
140
- {
141
- label: 'RANDOM 1',
142
- value: { dimensionId: 'RANDOM_DIM', dimensionValueId: 'RANDOM_VAL1' }
143
- }
144
- ],
145
- highlight: [
146
- {
147
- label: 'RANDOM 2',
148
- value: { dimensionId: 'RANDOM_DIM', dimensionValueId: 'RANDOM_VAL2' }
149
- },
150
- {
151
- label: 'RANDOM 3',
152
- value: { dimensionId: 'RANDOM_DIM', dimensionValueId: 'RANDOM_VAL3' }
153
- },
154
- {
155
- label: 'RANDOM 4',
156
- value: { dimensionId: 'RANDOM_DIM', dimensionValueId: 'RANDOM_VAL4' }
157
- }
158
- ]
159
- };
160
- expect(scatterStateFromNewProps(props, { ...state, type: SCATTER })).to.deep.equal(defaultKEIState);
161
- });
162
- it('mix of correct and wrong', () => {
163
- const props = { data: oecd_KEI, type: SCATTER };
164
- const state = {
165
- type: SCATTER,
166
- baseline: [
167
- {
168
- label: 'Country - France',
169
- value: { dimensionId: 'LOCATION', dimensionValueId: 'FRA' }
170
- }
171
- ],
172
- highlight: [
173
- {
174
- label: 'RANDOM 2',
175
- value: { dimensionId: 'RANDOM_DIM', dimensionValueId: 'RANDOM_VAL2' }
176
- },
177
- {
178
- label: 'Country - Austria',
179
- value: { dimensionId: 'LOCATION', dimensionValueId: 'AUT' }
180
- },
181
- {
182
- label: 'RANDOM 4',
183
- value: { dimensionId: 'RANDOM_DIM', dimensionValueId: 'RANDOM_VAL4' }
184
- }
185
- ]
186
- };
187
- const expected = {
188
- baseline: [
189
- {
190
- label: 'Country - France',
191
- value: { dimensionId: 'LOCATION', dimensionValueId: 'FRA' }
192
- }
193
- ],
194
- highlight: [
195
- {
196
- label: 'Country - Austria',
197
- value: { dimensionId: 'LOCATION', dimensionValueId: 'AUT' }
198
- }
199
- ]
200
- };
201
- expect(scatterStateFromNewProps(props, state)).to.deep.equal({ ...defaultKEIState, ...expected });
202
- });
203
- it('code display', () => {
204
- const props = { data: oecd_KEI, type: SCATTER, display: 'code' };
205
- const state = {
206
- type: SCATTER,
207
- baseline: [
208
- {
209
- label: 'Country - France',
210
- value: { dimensionId: 'LOCATION', dimensionValueId: 'FRA' }
211
- }
212
- ],
213
- highlight: [
214
- {
215
- label: 'Country - Austria',
216
- value: { dimensionId: 'LOCATION', dimensionValueId: 'AUT' }
217
- }
218
- ]
219
- };
220
- const expected = {
221
- ...defaultKEIState,
222
- baseline: [
223
- {
224
- label: 'LOCATION - FRA',
225
- value: { dimensionId: 'LOCATION', dimensionValueId: 'FRA' }
226
- }
227
- ],
228
- highlight: [
229
- {
230
- label: 'LOCATION - AUT',
231
- value: { dimensionId: 'LOCATION', dimensionValueId: 'AUT' }
232
- }
233
- ]
234
- };
235
- expect(scatterStateFromNewProps(props, state)).to.deep.equal(expected);
236
- });
237
- it('both display', () => {
238
- const props = { data: oecd_KEI, type: SCATTER, display: 'both' };
239
- const state = {
240
- type: SCATTER,
241
- baseline: [
242
- {
243
- label: 'Country - France',
244
- value: { dimensionId: 'LOCATION', dimensionValueId: 'FRA' }
245
- }
246
- ],
247
- highlight: [
248
- {
249
- label: 'Country - Austria',
250
- value: { dimensionId: 'LOCATION', dimensionValueId: 'AUT' }
251
- }
252
- ]
253
- };
254
- const expected = {
255
- ...defaultKEIState,
256
- baseline: [
257
- {
258
- label: '(LOCATION) Country - (FRA) France',
259
- value: { dimensionId: 'LOCATION', dimensionValueId: 'FRA' }
260
- }
261
- ],
262
- highlight: [
263
- {
264
- label: '(LOCATION) Country - (AUT) Austria',
265
- value: { dimensionId: 'LOCATION', dimensionValueId: 'AUT' }
266
- }
267
- ]
268
- };
269
- expect(scatterStateFromNewProps(props, state)).to.deep.equal(expected);
270
- });
271
- });
272
-
273
- describe('onChangeScatterDim tests', () => {
274
- it('no data', () => {
275
- const props = { type: SCATTER };
276
- expect(onChangeScatterDim(props, defaultKEIState)('LOCATION')).to.deep.equal({});
277
- });
278
- it('no value', () => {
279
- const props = { data: oecd_KEI, type: SCATTER };
280
- expect(onChangeScatterDim(props, scatterKEIDefaultState)(undefined)).to.deep.equal({});
281
- });
282
- it('correct value', () => {
283
- const props = { data: oecd_KEI, type: SCATTER };
284
- expect(onChangeScatterDim(props, defaultKEIState)('LOCATION')).to.deep.equal(customKEIState);
285
- });
286
- it('non correct value', () => {
287
- const props = { data: oecd_KEI, type: SCATTER };
288
- expect(onChangeScatterDim(props, scatterKEIDefaultState)('UNDEFINED')).to.deep.equal({});
289
- });
290
- });
291
-
292
- describe('onChangeScatterVal tests', () => {
293
- const onChange = (props, state) => onChangeScatterVal(props, state, 'scatterX', 'scatterY');
294
- it('no data', () => {
295
- expect(onChange({ type: SCATTER }, defaultKEIState)('AUS')).to.deep.equal({});
296
- });
297
- it('not scatter type', () => {
298
- expect(onChange({ data: oecd_KEI }, defaultKEIState)('AUS')).to.deep.equal({});
299
- });
300
- it('no value', () => {
301
- const props = { data: oecd_KEI, type: SCATTER };
302
- expect(onChange(props, scatterKEIDefaultState)(undefined)).to.deep.equal({});
303
- });
304
- it('correct value', () => {
305
- const props = { data: oecd_KEI, type: SCATTER };
306
- const expected = { scatterX: 'CZE', scatterY: 'AUT' }
307
- expect(onChange(props, scatterKEICustomState)('CZE')).to.deep.equal(expected);
308
- });
309
- it('non correct value', () => {
310
- const props = { data: oecd_KEI, type: SCATTER };
311
- expect(onChange(props, scatterKEIDefaultState)('UNDEFINED')).to.deep.equal({});
312
- });
313
- it('same value as other', () => {
314
- const props = { data: oecd_KEI, type: SCATTER };
315
- const expected = { scatterX: 'FRA', scatterY: 'AUS' };
316
- expect(onChange(props, customKEIState2)('FRA')).to.deep.equal(expected);
317
- });
318
- });
319
-
320
- describe('scatterStateValueToOption tests', () => {
321
- it('no data', () => {
322
- const props = { type: SCATTER, display: 'label' };
323
- expect(scatterStateValueToOption('scatterX', props, defaultKEIState)).to.deep.equal(undefined);
324
- });
325
- it('no state', () => {
326
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
327
- expect(scatterStateValueToOption('scatterX', props, undefined)).to.deep.equal(undefined);
328
- });
329
- it('not scatter type', () => {
330
- const props = { data: oecd_KEI, type: BAR, display: 'label' };
331
- expect(scatterStateValueToOption('scatterX', props, defaultKEIState)).to.deep.equal(undefined);
332
- });
333
- it('undefined state', () => {
334
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
335
- expect(scatterStateValueToOption('scatterX', props, undefinedState)).to.deep.equal(undefined);
336
- });
337
- it('non existing dimension', () => {
338
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
339
- expect(scatterStateValueToOption('scatterX', props, scatterUnexistingState)).to.deep.equal(undefined);
340
- });
341
- it('non existing property', () => {
342
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
343
- expect(scatterStateValueToOption('scatterZ', props, scatterUnexistingState)).to.deep.equal(undefined);
344
- });
345
- it('non existing value', () => {
346
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
347
- const state = { scatterDimension: 'SUBJECT', scatterX: 'random' }
348
- expect(scatterStateValueToOption('scatterX', props, state)).to.deep.equal(undefined);
349
- });
350
- it('label displayed', () => {
351
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
352
- const expected = { label: 'Industrial production, s.a.', value: 'PRINTO01' };
353
- expect(scatterStateValueToOption('scatterX', props, defaultKEIState)).to.deep.equal(expected);
354
- });
355
- it('default label displayed from unknown display props', () => {
356
- const props = { data: oecd_KEI, type: SCATTER, display: 'random' };
357
- const expected = { label: 'Industrial production, s.a.', value: 'PRINTO01' };
358
- expect(scatterStateValueToOption('scatterX', props, defaultKEIState)).to.deep.equal(expected);
359
- });
360
- it('code displayed', () => {
361
- const props = { data: oecd_KEI, type: SCATTER, display: 'code' };
362
- const expected = { label: 'PRINTO01', value: 'PRINTO01' };
363
- expect(scatterStateValueToOption('scatterX', props, defaultKEIState)).to.deep.equal(expected);
364
- });
365
- it('both displayed', () => {
366
- const props = { data: oecd_KEI, type: SCATTER, display: 'both' };
367
- const expected = { label: '(PRINTO01) Industrial production, s.a.', value: 'PRINTO01' };
368
- expect(scatterStateValueToOption('scatterX', props, defaultKEIState)).to.deep.equal(expected);
369
- });
370
- it('scatterY', () => {
371
- const props = { data: oecd_KEI, type: SCATTER, display: 'code' };
372
- const expected = { label: 'PRMNTO01', value: 'PRMNTO01' };
373
- expect(scatterStateValueToOption('scatterY', props, defaultKEIState)).to.deep.equal(expected);
374
- });
375
- it('custom', () => {
376
- const props = { data: oecd_KEI, type: SCATTER, display: 'code' };
377
- const expected = { label: 'FRA', value: 'FRA' };
378
- expect(scatterStateValueToOption('scatterY', props, customKEIState2)).to.deep.equal(expected);
379
- })
380
- });
381
-
382
- describe('scatterValueOptions tests', () => {
383
- it('no data', () => {
384
- const props = { type: SCATTER, display: 'label' };
385
- expect(scatterValueOptions(props, defaultKEIState)).to.deep.equal([]);
386
- });
387
- it('no state', () => {
388
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
389
- expect(scatterValueOptions(props, undefined)).to.deep.equal([]);
390
- });
391
- it('not scatter type', () => {
392
- const props = { data: oecd_KEI, type: BAR, display: 'label' };
393
- expect(scatterValueOptions(props, defaultKEIState)).to.deep.equal([]);
394
- });
395
- it('undefined state', () => {
396
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
397
- expect(scatterValueOptions(props, undefinedState)).to.deep.equal([]);
398
- });
399
- it('non existing dimension', () => {
400
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
401
- expect(scatterValueOptions(props, scatterUnexistingState)).to.deep.equal([]);
402
- });
403
- it('dimension with just one value', () => {
404
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
405
- expect(scatterValueOptions(props, { symbolDimension: 'MEASURE' })).to.deep.equal([]);
406
- });
407
- it('label displayed', () => {
408
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
409
- const expected = [
410
- { label: 'Industrial production, s.a.', value: 'PRINTO01' },
411
- { label: 'Total manufacturing, s.a.', value: 'PRMNTO01' }
412
- ];
413
- expect(scatterValueOptions(props, defaultKEIState)).to.deep.equal(expected);
414
- });
415
- it('default label displayed from unexisting display prop', () => {
416
- const props = { data: oecd_KEI, type: SCATTER, display: 'random' };
417
- const expected = [
418
- { label: 'Industrial production, s.a.', value: 'PRINTO01' },
419
- { label: 'Total manufacturing, s.a.', value: 'PRMNTO01' }
420
- ];
421
- expect(scatterValueOptions(props, defaultKEIState)).to.deep.equal(expected);
422
- });
423
- it('code displayed', () => {
424
- const props = { data: oecd_KEI, type: SCATTER, display: 'code' };
425
- const expected = [
426
- { label: 'PRINTO01', value: 'PRINTO01' },
427
- { label: 'PRMNTO01', value: 'PRMNTO01' }
428
- ];
429
- expect(scatterValueOptions(props, defaultKEIState)).to.deep.equal(expected);
430
- });
431
- it('both displayed', () => {
432
- const props = { data: oecd_KEI, type: SCATTER, display: 'both' };
433
- const expected = [
434
- { label: '(PRINTO01) Industrial production, s.a.', value: 'PRINTO01' },
435
- { label: '(PRMNTO01) Total manufacturing, s.a.', value: 'PRMNTO01' }
436
- ];
437
- expect(scatterValueOptions(props, defaultKEIState)).to.deep.equal(expected);
438
- });
439
- it('custom dimension', () => {
440
- const props = { data: oecd_KEI, type: SCATTER, display: 'label' };
441
- const expected = [
442
- { label: 'Australia', value: "AUS" },
443
- { label: 'Austria', value: 'AUT' },
444
- { label: 'Belgium', value: 'BEL' },
445
- { label: 'Canada', value: 'CAN' },
446
- { label: 'Czech Republic', value: 'CZE' },
447
- { label: 'Denmark', value: 'DNK' },
448
- { label: 'Finland', value: 'FIN' },
449
- { label: 'France', value: 'FRA' },
450
- { label: 'Chile', value: 'CHL' },
451
- { label: 'Estonia', value: 'EST' }
452
- ];
453
- expect(scatterValueOptions(props, customKEIState)).to.deep.equal(expected);
454
- });
455
- });