@sis-cc/dotstatsuite-components 16.1.6 → 16.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/rules2/src/enhanceObservations.js +1 -4
- package/lib/rules2/src/getOneValueDimensions.js +1 -1
- package/lib/rules2/src/index.js +9 -0
- package/lib/rules2/src/table/getFlagsAndNotes.js +3 -1
- package/lib/rules2/src/table/getLayout.js +1 -1
- package/lib/rules2/src/table/getLayoutData.js +1 -4
- package/lib/rules2/src/table/getTableLabelAccessor.js +57 -0
- package/package.json +1 -1
- package/src/rules2/src/enhanceObservations.js +1 -4
- package/src/rules2/src/getOneValueDimensions.js +1 -2
- package/src/rules2/src/index.js +1 -0
- package/src/rules2/src/table/getFlagsAndNotes.js +3 -1
- package/src/rules2/src/table/getLayout.js +1 -1
- package/src/rules2/src/table/getLayoutData.js +1 -4
- package/src/rules2/src/table/getTableLabelAccessor.js +53 -0
- package/test/getLayoutData.test.js +8 -8
- package/test/getOneValueDimensions.test.js +3 -0
- package/test/getTableLabelAccessor.test.js +25 -0
|
@@ -36,13 +36,10 @@ var parseAttributesValues = function parseAttributesValues(obs, attributes, inde
|
|
|
36
36
|
|
|
37
37
|
return R.addIndex(R.reduce)(function (acc, valueIndex, attrIndex) {
|
|
38
38
|
var attribute = R.nth(attrIndex, attributes);
|
|
39
|
-
if (R.isNil(attribute) || !R.
|
|
39
|
+
if (R.isNil(attribute) || !R.prop('series', attribute)) {
|
|
40
40
|
return acc;
|
|
41
41
|
}
|
|
42
42
|
var value = R.nth(valueIndex, attribute.values || []);
|
|
43
|
-
if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value), _constants.REJECTED_VALUE_IDS)) {
|
|
44
|
-
value = null;
|
|
45
|
-
}
|
|
46
43
|
var relationship = R.propOr([], 'relationship', attribute);
|
|
47
44
|
var coordinates = {};
|
|
48
45
|
var serieKey = R.pipe(function (dims) {
|
|
@@ -39,7 +39,7 @@ var getOneValueDimensions = exports.getOneValueDimensions = function getOneValue
|
|
|
39
39
|
})(acc);
|
|
40
40
|
}, {}, attributes);
|
|
41
41
|
return R.reduce(function (acc, dim) {
|
|
42
|
-
if (R.length(dim.values || []) !== 1
|
|
42
|
+
if (R.length(dim.values || []) !== 1) {
|
|
43
43
|
return acc;
|
|
44
44
|
}
|
|
45
45
|
var attrValues = R.propOr({}, dim.id, indexedRelevantAttributes);
|
package/lib/rules2/src/index.js
CHANGED
|
@@ -362,4 +362,13 @@ Object.defineProperty(exports, 'getTableProps', {
|
|
|
362
362
|
get: function get() {
|
|
363
363
|
return _getTableProps.getTableProps;
|
|
364
364
|
}
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
var _getTableLabelAccessor = require('./table/getTableLabelAccessor');
|
|
368
|
+
|
|
369
|
+
Object.defineProperty(exports, 'getTableLabelAccessor', {
|
|
370
|
+
enumerable: true,
|
|
371
|
+
get: function get() {
|
|
372
|
+
return _getTableLabelAccessor.getTableLabelAccessor;
|
|
373
|
+
}
|
|
365
374
|
});
|
|
@@ -9,6 +9,8 @@ var _ramda = require('ramda');
|
|
|
9
9
|
|
|
10
10
|
var R = _interopRequireWildcard(_ramda);
|
|
11
11
|
|
|
12
|
+
var _constants = require('../constants');
|
|
13
|
+
|
|
12
14
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
13
15
|
|
|
14
16
|
var getFlagsAndNotes = exports.getFlagsAndNotes = function getFlagsAndNotes(attributesValues, customAttributes) {
|
|
@@ -20,7 +22,7 @@ var getFlagsAndNotes = exports.getFlagsAndNotes = function getFlagsAndNotes(attr
|
|
|
20
22
|
return acc;
|
|
21
23
|
}
|
|
22
24
|
var attr = R.prop(id, attributesValues);
|
|
23
|
-
if (R.isNil(attr.value)) {
|
|
25
|
+
if (R.isNil(attr.value) || !R.pathOr(true, ['value', 'display'], attr) || !R.propOr(true, 'display', attr) || R.includes(R.path(['value', 'id'], attr), _constants.REJECTED_VALUE_IDS)) {
|
|
24
26
|
return acc;
|
|
25
27
|
}
|
|
26
28
|
return R.append(index < flagsIds.length ? R.assoc('code', R.path(['value', 'id'], attr), attr) : attr, acc);
|
|
@@ -31,7 +31,7 @@ var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, co
|
|
|
31
31
|
}))(dimensions);
|
|
32
32
|
var indexedFixedDimsValues = R.reduce(function (acc, dim) {
|
|
33
33
|
var value = R.head(dim.values);
|
|
34
|
-
return !dim.display
|
|
34
|
+
return !dim.display ? acc : R.assoc(dim.id, R.head(dim.values), acc);
|
|
35
35
|
}, {}, fixedDimensions);
|
|
36
36
|
var indexedHeaderIds = R.indexBy(R.identity, layoutIds.header);
|
|
37
37
|
var indexedSectionsIds = R.indexBy(R.identity, layoutIds.sections);
|
|
@@ -145,10 +145,7 @@ var getSubLayoutData = function getSubLayoutData(series, _definition, _ref) {
|
|
|
145
145
|
var values = R.reduce(function (_acc, id) {
|
|
146
146
|
if (R.has(id, dimValues)) {
|
|
147
147
|
var _value = R.prop(id, dimValues);
|
|
148
|
-
|
|
149
|
-
return _acc;
|
|
150
|
-
}
|
|
151
|
-
return R.append(R.dissoc('display', _value), _acc);
|
|
148
|
+
return R.append(_value, _acc);
|
|
152
149
|
}
|
|
153
150
|
if (R.has(id, fixedDimValues)) {
|
|
154
151
|
return R.append(R.prop(id, fixedDimValues), _acc);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTableLabelAccessor = undefined;
|
|
7
|
+
|
|
8
|
+
var _ramda = require('ramda');
|
|
9
|
+
|
|
10
|
+
var R = _interopRequireWildcard(_ramda);
|
|
11
|
+
|
|
12
|
+
var _src = require('../../../rules/src');
|
|
13
|
+
|
|
14
|
+
var _constants = require('../constants');
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
17
|
+
|
|
18
|
+
var getRefinedMissinParentsLabels = R.pipe(R.propOr([], 'missingParents'), R.reduce(function (acc, par) {
|
|
19
|
+
if (!R.propOr(true, 'display', par) || R.includes(par.id, _constants.REJECTED_VALUE_IDS)) {
|
|
20
|
+
return acc;
|
|
21
|
+
}
|
|
22
|
+
return R.append((0, _src.dimensionValueDisplay)('label')(par), acc);
|
|
23
|
+
}, []));
|
|
24
|
+
|
|
25
|
+
var granularDisplay = function granularDisplay(display, value) {
|
|
26
|
+
if (display === 'label') {
|
|
27
|
+
return R.converge(function (missingParents, label) {
|
|
28
|
+
return R.isEmpty(missingParents) ? label : R.join(' > ', R.append(label, missingParents));
|
|
29
|
+
}, [getRefinedMissinParentsLabels, (0, _src.dimensionValueDisplay)(display)])(value);
|
|
30
|
+
} else if (display === 'both') {
|
|
31
|
+
return '(' + granularDisplay('code', value) + ') ' + granularDisplay('label', value);
|
|
32
|
+
}
|
|
33
|
+
return (0, _src.dimensionValueDisplay)(display)(value);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var combinedDisplay = function combinedDisplay(_display) {
|
|
37
|
+
return R.pipe(R.reduce(function (acc, val) {
|
|
38
|
+
if ((!R.propOr(true, 'display', val) || R.includes(val.id, _constants.REJECTED_VALUE_IDS)) && _display === 'label') {
|
|
39
|
+
return acc;
|
|
40
|
+
}
|
|
41
|
+
return R.append(granularDisplay(_display, val), acc);
|
|
42
|
+
}, []), R.join(', '));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var getTableLabelAccessor = exports.getTableLabelAccessor = function getTableLabelAccessor(display) {
|
|
46
|
+
return function (item) {
|
|
47
|
+
if (!R.is(Array, item)) {
|
|
48
|
+
return granularDisplay(display, item);
|
|
49
|
+
}
|
|
50
|
+
if (display === 'both') {
|
|
51
|
+
return R.converge(function (ids, labels) {
|
|
52
|
+
return '(' + ids + ') ' + labels;
|
|
53
|
+
}, [combinedDisplay('code'), combinedDisplay('label')])(item);
|
|
54
|
+
}
|
|
55
|
+
return combinedDisplay(display)(item);
|
|
56
|
+
};
|
|
57
|
+
};
|
package/package.json
CHANGED
|
@@ -16,13 +16,10 @@ const parseAttributesValues = (obs, attributes, indexedDimensions) => {
|
|
|
16
16
|
return R.addIndex(R.reduce)(
|
|
17
17
|
(acc, valueIndex, attrIndex) => {
|
|
18
18
|
const attribute = R.nth(attrIndex, attributes);
|
|
19
|
-
if (R.isNil(attribute) || !R.
|
|
19
|
+
if (R.isNil(attribute) || !R.prop('series', attribute)) {
|
|
20
20
|
return acc;
|
|
21
21
|
}
|
|
22
22
|
let value = R.nth(valueIndex, attribute.values || []);
|
|
23
|
-
if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value), REJECTED_VALUE_IDS)) {
|
|
24
|
-
value = null;
|
|
25
|
-
}
|
|
26
23
|
const relationship = R.propOr([], 'relationship', attribute);
|
|
27
24
|
let coordinates = {};
|
|
28
25
|
const serieKey = R.pipe(
|
|
@@ -22,8 +22,7 @@ export const getOneValueDimensions = (dimensions, attributes) => {
|
|
|
22
22
|
);
|
|
23
23
|
return R.reduce(
|
|
24
24
|
(acc, dim) => {
|
|
25
|
-
if (R.length(dim.values || []) !== 1
|
|
26
|
-
|| R.includes(R.path(['values', 0, 'id'], dim), REJECTED_VALUE_IDS)) {
|
|
25
|
+
if (R.length(dim.values || []) !== 1) {
|
|
27
26
|
return acc;
|
|
28
27
|
}
|
|
29
28
|
const attrValues = R.propOr({}, dim.id, indexedRelevantAttributes);
|
package/src/rules2/src/index.js
CHANGED
|
@@ -41,3 +41,4 @@ export { getCells } from './table/getCells';
|
|
|
41
41
|
export { getCuratedCells } from './table/getCuratedCells';
|
|
42
42
|
export { prepareData } from './prepareData';
|
|
43
43
|
export { getTableProps } from './table/getTableProps';
|
|
44
|
+
export { getTableLabelAccessor } from './table/getTableLabelAccessor';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
|
+
import { REJECTED_VALUE_IDS } from '../constants';
|
|
2
3
|
|
|
3
4
|
export const getFlagsAndNotes = (attributesValues, customAttributes) => {
|
|
4
5
|
const flagsIds = R.propOr([], 'flags', customAttributes);
|
|
@@ -10,7 +11,8 @@ export const getFlagsAndNotes = (attributesValues, customAttributes) => {
|
|
|
10
11
|
return acc;
|
|
11
12
|
}
|
|
12
13
|
const attr = R.prop(id, attributesValues);
|
|
13
|
-
if (R.isNil(attr.value))
|
|
14
|
+
if (R.isNil(attr.value) || !R.pathOr(true, ['value', 'display'], attr) || !R.propOr(true, 'display', attr)
|
|
15
|
+
|| R.includes(R.path(['value', 'id'], attr), REJECTED_VALUE_IDS)) {
|
|
14
16
|
return acc;
|
|
15
17
|
}
|
|
16
18
|
return R.append(index < flagsIds.length ? R.assoc('code', R.path(['value', 'id'], attr), attr) : attr, acc);
|
|
@@ -10,7 +10,7 @@ export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted, f
|
|
|
10
10
|
const indexedFixedDimsValues = R.reduce(
|
|
11
11
|
(acc, dim) => {
|
|
12
12
|
const value = R.head(dim.values);
|
|
13
|
-
return !dim.display
|
|
13
|
+
return !dim.display ? acc : R.assoc(dim.id, R.head(dim.values), acc);
|
|
14
14
|
},
|
|
15
15
|
{},
|
|
16
16
|
fixedDimensions,
|
|
@@ -122,10 +122,7 @@ const getSubLayoutData = (series, _definition, { metadataCoordinates, attributes
|
|
|
122
122
|
(_acc, id) => {
|
|
123
123
|
if (R.has(id, dimValues)) {
|
|
124
124
|
const value = R.prop(id, dimValues);
|
|
125
|
-
|
|
126
|
-
return _acc;
|
|
127
|
-
}
|
|
128
|
-
return R.append(R.dissoc('display', value), _acc);
|
|
125
|
+
return R.append(value, _acc);
|
|
129
126
|
}
|
|
130
127
|
if (R.has(id, fixedDimValues)) {
|
|
131
128
|
return R.append(R.prop(id, fixedDimValues), _acc);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
import { dimensionValueDisplay } from '../../../rules/src';
|
|
3
|
+
import { REJECTED_VALUE_IDS } from '../constants';
|
|
4
|
+
|
|
5
|
+
const getRefinedMissinParentsLabels = R.pipe(
|
|
6
|
+
R.propOr([], 'missingParents'),
|
|
7
|
+
R.reduce((acc, par) => {
|
|
8
|
+
if (!R.propOr(true, 'display', par) || R.includes(par.id, REJECTED_VALUE_IDS)) {
|
|
9
|
+
return acc;
|
|
10
|
+
}
|
|
11
|
+
return R.append(dimensionValueDisplay('label')(par), acc);
|
|
12
|
+
}, []),
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const granularDisplay = (display, value) => {
|
|
16
|
+
if (display === 'label') {
|
|
17
|
+
return R.converge(
|
|
18
|
+
(missingParents, label) =>
|
|
19
|
+
R.isEmpty(missingParents) ? label : R.join(' > ', R.append(label, missingParents)),
|
|
20
|
+
[
|
|
21
|
+
getRefinedMissinParentsLabels,
|
|
22
|
+
dimensionValueDisplay(display),
|
|
23
|
+
],
|
|
24
|
+
)(value);
|
|
25
|
+
} else if (display === 'both') {
|
|
26
|
+
return `(${granularDisplay('code', value)}) ${granularDisplay('label', value)}`;
|
|
27
|
+
}
|
|
28
|
+
return dimensionValueDisplay(display)(value);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const combinedDisplay = _display => R.pipe(
|
|
32
|
+
R.reduce((acc, val) => {
|
|
33
|
+
if ((!R.propOr(true, 'display', val) || R.includes(val.id, REJECTED_VALUE_IDS))
|
|
34
|
+
&& _display === 'label') {
|
|
35
|
+
return acc;
|
|
36
|
+
}
|
|
37
|
+
return R.append(granularDisplay(_display, val), acc);
|
|
38
|
+
}, []),
|
|
39
|
+
R.join(', '),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export const getTableLabelAccessor = display => item => {
|
|
43
|
+
if (!R.is(Array, item)) {
|
|
44
|
+
return granularDisplay(display, item);
|
|
45
|
+
}
|
|
46
|
+
if (display === 'both') {
|
|
47
|
+
return R.converge((ids, labels) => `(${ids}) ${labels}`, [
|
|
48
|
+
combinedDisplay('code'),
|
|
49
|
+
combinedDisplay('label'),
|
|
50
|
+
])(item);
|
|
51
|
+
}
|
|
52
|
+
return combinedDisplay(display)(item);
|
|
53
|
+
};
|
|
@@ -62,28 +62,28 @@ describe('getLayoutData tests', () => {
|
|
|
62
62
|
{ data: [{ dimension: { id: 'S' }, value: { id: 'S_V1' } }], key: 'S=S_V1', flags: [], sideProps: null, coordinates: { S: 'S_V1' } },
|
|
63
63
|
[
|
|
64
64
|
{
|
|
65
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1' }, { id: 'R2_V1' }, { id: 'ATTR_V1' }] }],
|
|
65
|
+
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V1' }] }],
|
|
66
66
|
key: 'R1=R1_V1:R2=R2_V1',
|
|
67
67
|
coordinates: { R1: 'R1_V1', R2: 'R2_V1', S: 'S_V1' },
|
|
68
68
|
flags: [],
|
|
69
69
|
sideProps: null
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1' }, { id: 'ATTR_V2' }] }],
|
|
72
|
+
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V2' }] }],
|
|
73
73
|
key: 'R1=R1_V1:R2=R2_V2',
|
|
74
74
|
coordinates: { R1: 'R1_V1', R2: 'R2_V2', S: 'S_V1' },
|
|
75
75
|
flags: [],
|
|
76
76
|
sideProps: null
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2' }, { id: 'R2_V1' }, { id: 'ATTR_V3' }] }],
|
|
79
|
+
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V3' }] }],
|
|
80
80
|
key: 'R1=R1_V2:R2=R2_V1',
|
|
81
81
|
coordinates: { R1: 'R1_V2', R2: 'R2_V1', S: 'S_V1' },
|
|
82
82
|
flags: [],
|
|
83
83
|
sideProps: null
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2' }, { id: 'ATTR_V4' }] }],
|
|
86
|
+
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V4' }] }],
|
|
87
87
|
key: 'R1=R1_V2:R2=R2_V2',
|
|
88
88
|
coordinates: { R1: 'R1_V2', R2: 'R2_V2', S: 'S_V1' },
|
|
89
89
|
flags: [],
|
|
@@ -95,28 +95,28 @@ describe('getLayoutData tests', () => {
|
|
|
95
95
|
{ data: [{ dimension: { id: 'S' }, value: { id: 'S_V2' } }], key: 'S=S_V2', flags: [], sideProps: null, coordinates: { S: 'S_V2' } },
|
|
96
96
|
[
|
|
97
97
|
{
|
|
98
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1' }, { id: 'R2_V1' }, { id: 'ATTR_V1' }] }],
|
|
98
|
+
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V1' }] }],
|
|
99
99
|
key: 'R1=R1_V1:R2=R2_V1',
|
|
100
100
|
coordinates: { R1: 'R1_V1', R2: 'R2_V1', S: 'S_V2' },
|
|
101
101
|
flags: [],
|
|
102
102
|
sideProps: null
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1' }, { id: 'ATTR_V2' }] }],
|
|
105
|
+
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V2' }] }],
|
|
106
106
|
key: 'R1=R1_V1:R2=R2_V2',
|
|
107
107
|
coordinates: { R1: 'R1_V1', R2: 'R2_V2', S: 'S_V2' },
|
|
108
108
|
flags: [],
|
|
109
109
|
sideProps: null
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2' }, { id: 'R2_V1' }, { id: 'ATTR_V3' }] }],
|
|
112
|
+
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V3' }] }],
|
|
113
113
|
key: 'R1=R1_V2:R2=R2_V1',
|
|
114
114
|
coordinates: { R1: 'R1_V2', R2: 'R2_V1', S: 'S_V2' },
|
|
115
115
|
flags: [],
|
|
116
116
|
sideProps: null
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2' }, { id: 'ATTR_V4' }] }],
|
|
119
|
+
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V4' }] }],
|
|
120
120
|
key: 'R1=R1_V2:R2=R2_V2',
|
|
121
121
|
coordinates: { R1: 'R1_V2', R2: 'R2_V2', S: 'S_V2' },
|
|
122
122
|
flags: [],
|
|
@@ -24,6 +24,9 @@ describe('getOneValueDimensions tests', () => {
|
|
|
24
24
|
expect(getOneValueDimensions(dimensions, attributes)).to.deep.equal([
|
|
25
25
|
{ id: 'd0', values: [{ id: 'v' }], attrValues: { a1: { id: 'a1', header: true, values: [{ id: 'v' }], relationship: ['d0'], value: { id: 'v' } } } },
|
|
26
26
|
{ id: 'd1', values: [{ id: 'v' }], attrValues: {} },
|
|
27
|
+
{ id: 'd2', values: [{ id: 'v' }], display: false, attrValues: {} },
|
|
28
|
+
{ id: 'd3', values: [{ id: 'v', display: false }], attrValues: {} },
|
|
29
|
+
{ id: 'd4', values: [{ id: '_T' }], attrValues: {} },
|
|
27
30
|
])
|
|
28
31
|
});
|
|
29
32
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getTableLabelAccessor } from '../src/rules2/src/table/getTableLabelAccessor';
|
|
3
|
+
|
|
4
|
+
describe('getTableLabelAccessor tests', () => {
|
|
5
|
+
const values = [
|
|
6
|
+
{ id: 'V0', name: 'Value 0', display: false },
|
|
7
|
+
{ id: 'V1', name: 'Value 1', missingParents: [{ id: 'P0', name: 'Parent 0' }, { id: 'P1', name: 'Parent 1', display: false }] },
|
|
8
|
+
{ id: '_T', name: 'Value 2' },
|
|
9
|
+
];
|
|
10
|
+
it('combination label display', () => {
|
|
11
|
+
expect(getTableLabelAccessor('label')(values)).to.deep.equal('Parent 0 > Value 1');
|
|
12
|
+
});
|
|
13
|
+
it('combination code display', () => {
|
|
14
|
+
expect(getTableLabelAccessor('code')(values)).to.deep.equal('V0, V1, _T');
|
|
15
|
+
});
|
|
16
|
+
it('combination both display', () => {
|
|
17
|
+
expect(getTableLabelAccessor('both')(values)).to.deep.equal('(V0, V1, _T) Parent 0 > Value 1');
|
|
18
|
+
});
|
|
19
|
+
it('single value witrh missingParents', () => {
|
|
20
|
+
expect(getTableLabelAccessor('label')(values[1])).to.deep.equal('Parent 0 > Value 1');
|
|
21
|
+
});
|
|
22
|
+
it('not displayed single value', () => {
|
|
23
|
+
expect(getTableLabelAccessor('both')(values[0])).to.deep.equal('(V0) Value 0');
|
|
24
|
+
});
|
|
25
|
+
});
|