@genesislcap/pbc-reporting-ui 15.19.0 → 15.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +4247 -5382
- package/dist/dts/react.d.ts +44 -44
- package/dist/react.cjs +65 -65
- package/dist/react.mjs +57 -57
- package/package.json +22 -23
- package/.env +0 -3
- package/api-extractor.json +0 -4
- package/dist/dts/new/main/edit-config/col-filters/col-filters-grid.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/col-filters/col-filters-grid.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/row-filters/row-filters.helpers.test.d.ts +0 -2
- package/dist/dts/new/main/edit-config/row-filters/row-filters.helpers.test.d.ts.map +0 -1
- package/dist/dts/new/main/edit-config/shared/datasource-data-base-component.test.d.ts +0 -5
- package/dist/dts/new/main/edit-config/shared/datasource-data-base-component.test.d.ts.map +0 -1
- package/dist/dts/new/utils/alias-generator.test.d.ts +0 -2
- package/dist/dts/new/utils/alias-generator.test.d.ts.map +0 -1
- package/dist/dts/new/utils/endpoint.test.d.ts +0 -2
- package/dist/dts/new/utils/endpoint.test.d.ts.map +0 -1
- package/dist/dts/new/utils/transformers.test.d.ts +0 -2
- package/dist/dts/new/utils/transformers.test.d.ts.map +0 -1
- package/dist/dts/new/utils/validators.test.d.ts +0 -2
- package/dist/dts/new/utils/validators.test.d.ts.map +0 -1
- package/dist/dts/old/main/main.test.d.ts +0 -2
- package/dist/dts/old/main/main.test.d.ts.map +0 -1
- package/dist/dts/old/utils/filterObjectArray.test.d.ts +0 -2
- package/dist/dts/old/utils/filterObjectArray.test.d.ts.map +0 -1
- package/dist/esm/new/main/edit-config/col-filters/col-filters-grid.helpers.test.js +0 -200
- package/dist/esm/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.js +0 -152
- package/dist/esm/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.js +0 -629
- package/dist/esm/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.js +0 -268
- package/dist/esm/new/main/edit-config/row-filters/row-filters.helpers.test.js +0 -1
- package/dist/esm/new/main/edit-config/shared/datasource-data-base-component.test.js +0 -426
- package/dist/esm/new/utils/alias-generator.test.js +0 -36
- package/dist/esm/new/utils/endpoint.test.js +0 -162
- package/dist/esm/new/utils/transformers.test.js +0 -469
- package/dist/esm/new/utils/validators.test.js +0 -139
- package/dist/esm/old/main/main.test.js +0 -5
- package/dist/esm/old/utils/filterObjectArray.test.js +0 -46
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/globals.d.ts +0 -7
- package/src/index.federated.ts +0 -1
- package/src/index.ts +0 -8
- package/src/new/components/clone-report-config-modal/clone-report-config-modal.styles.ts +0 -47
- package/src/new/components/clone-report-config-modal/clone-report-config-modal.template.ts +0 -55
- package/src/new/components/clone-report-config-modal/clone-report-config-modal.ts +0 -173
- package/src/new/components/components.ts +0 -118
- package/src/new/components/renderers/data-transform-renderer.ts +0 -111
- package/src/new/components/reporting-configurations/reporting-configurations.styles.ts +0 -42
- package/src/new/components/reporting-configurations/reporting-configurations.template.ts +0 -59
- package/src/new/components/reporting-configurations/reporting-configurations.ts +0 -366
- package/src/new/components/shared/file-template-picker.template.ts +0 -45
- package/src/new/lib/redux-store/README.md +0 -55
- package/src/new/lib/redux-store/index.ts +0 -2
- package/src/new/lib/redux-store/state-utils.ts +0 -1
- package/src/new/lib/redux-store/store.ts +0 -135
- package/src/new/main/edit-config/base-config/base-config.styles.ts +0 -26
- package/src/new/main/edit-config/base-config/base-config.template.ts +0 -71
- package/src/new/main/edit-config/base-config/base-config.ts +0 -116
- package/src/new/main/edit-config/col-filters/col-filters-grid.helpers.test.ts +0 -232
- package/src/new/main/edit-config/col-filters/col-filters-grid.helpers.ts +0 -35
- package/src/new/main/edit-config/col-filters/col-filters-grid.styles.ts +0 -22
- package/src/new/main/edit-config/col-filters/col-filters-grid.ts +0 -150
- package/src/new/main/edit-config/col-filters/col-filters-grid.types.ts +0 -7
- package/src/new/main/edit-config/col-filters/col-filters-tutorial.ts +0 -25
- package/src/new/main/edit-config/col-filters/col-fitlers-grid.template.ts +0 -15
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.ts +0 -187
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.ts +0 -89
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.styles.ts +0 -22
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.template.ts +0 -14
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.ts +0 -119
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.types.ts +0 -10
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-tutorial.ts +0 -33
- package/src/new/main/edit-config/config-journey-orchestrator.styles.ts +0 -120
- package/src/new/main/edit-config/config-journey-orchestrator.template.ts +0 -149
- package/src/new/main/edit-config/config-journey-orchestrator.ts +0 -92
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms-tutorial.ts +0 -127
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.ts +0 -799
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.ts +0 -371
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.styles.ts +0 -22
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.template.ts +0 -21
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.ts +0 -162
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.types.ts +0 -211
- package/src/new/main/edit-config/data-transforms-derived-fields/date-format-modal/date-format-modal.styles.ts +0 -79
- package/src/new/main/edit-config/data-transforms-derived-fields/date-format-modal/date-format-modal.template.ts +0 -217
- package/src/new/main/edit-config/data-transforms-derived-fields/date-format-modal/date-format-modal.ts +0 -280
- package/src/new/main/edit-config/data-transforms-derived-fields/date-format-modal/index.ts +0 -1
- package/src/new/main/edit-config/data-transforms-derived-fields/format-warning.ts +0 -43
- package/src/new/main/edit-config/data-transforms-derived-fields/number-format-modal/index.ts +0 -1
- package/src/new/main/edit-config/data-transforms-derived-fields/number-format-modal/number-format-modal.styles.ts +0 -68
- package/src/new/main/edit-config/data-transforms-derived-fields/number-format-modal/number-format-modal.template.ts +0 -93
- package/src/new/main/edit-config/data-transforms-derived-fields/number-format-modal/number-format-modal.ts +0 -152
- package/src/new/main/edit-config/datasource-config/datasource-config-container.styles.ts +0 -22
- package/src/new/main/edit-config/datasource-config/datasource-config-item.styles.ts +0 -76
- package/src/new/main/edit-config/datasource-config/datasource-config-item.template.ts +0 -141
- package/src/new/main/edit-config/datasource-config/datasource-config-item.ts +0 -212
- package/src/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.ts +0 -341
- package/src/new/main/edit-config/datasource-config/datasources-config-container.helpers.ts +0 -99
- package/src/new/main/edit-config/datasource-config/datasources-config-container.template.ts +0 -68
- package/src/new/main/edit-config/datasource-config/datasources-config-container.ts +0 -55
- package/src/new/main/edit-config/datasource-config/types.ts +0 -6
- package/src/new/main/edit-config/outputs-config/outputs-config.style.ts +0 -11
- package/src/new/main/edit-config/outputs-config/outputs-config.template.ts +0 -66
- package/src/new/main/edit-config/outputs-config/outputs-config.ts +0 -66
- package/src/new/main/edit-config/row-filters/row-filters-tutorial.styles.ts +0 -16
- package/src/new/main/edit-config/row-filters/row-filters-tutorial.template.ts +0 -229
- package/src/new/main/edit-config/row-filters/row-filters-tutorial.ts +0 -15
- package/src/new/main/edit-config/row-filters/row-filters.helpers.test.ts +0 -2
- package/src/new/main/edit-config/row-filters/row-filters.helpers.ts +0 -53
- package/src/new/main/edit-config/row-filters/row-filters.styles.ts +0 -23
- package/src/new/main/edit-config/row-filters/row-filters.template.ts +0 -15
- package/src/new/main/edit-config/row-filters/row-filters.ts +0 -58
- package/src/new/main/edit-config/row-filters/row-filters.types.ts +0 -14
- package/src/new/main/edit-config/scheduling/scheduling.styles.ts +0 -59
- package/src/new/main/edit-config/scheduling/scheduling.template.ts +0 -80
- package/src/new/main/edit-config/scheduling/scheduling.ts +0 -101
- package/src/new/main/edit-config/shared/datasource-data-base-component.helpers.ts.ts +0 -250
- package/src/new/main/edit-config/shared/datasource-data-base-component.test.ts +0 -568
- package/src/new/main/edit-config/shared/datasource-data-base-component.ts +0 -65
- package/src/new/main/edit-config/shared/datasource-data-base-component.types.ts +0 -55
- package/src/new/main/edit-config/shared/index.ts +0 -3
- package/src/new/main/edit-config/tabbed-datasource-container/index.ts +0 -2
- package/src/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.styles.ts +0 -12
- package/src/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.template.ts +0 -29
- package/src/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.ts +0 -69
- package/src/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.types.ts +0 -7
- package/src/new/main/generated-reports/generated-reports.styles.ts +0 -15
- package/src/new/main/generated-reports/generated-reports.template.ts +0 -29
- package/src/new/main/generated-reports/generated-reports.ts +0 -270
- package/src/new/main/index.ts +0 -3
- package/src/new/main/main.styles.ts +0 -31
- package/src/new/main/main.template.ts +0 -92
- package/src/new/main/main.ts +0 -117
- package/src/new/main/report-destinations/report-destinations.template.ts +0 -39
- package/src/new/main/report-destinations/report-destinations.ts +0 -63
- package/src/new/store/index.ts +0 -3
- package/src/new/store/slices/base-config.ts +0 -50
- package/src/new/store/slices/datasources-config.ts +0 -297
- package/src/new/store/slices/index.ts +0 -3
- package/src/new/store/slices/types.ts +0 -90
- package/src/new/store/store.ts +0 -36
- package/src/new/store/types.ts +0 -10
- package/src/new/styles/constraints.styles.ts +0 -32
- package/src/new/styles/forms.styles.ts +0 -38
- package/src/new/styles/index.ts +0 -3
- package/src/new/styles/misc.styles.ts +0 -25
- package/src/new/types/display.ts +0 -4
- package/src/new/types/index.ts +0 -4
- package/src/new/types/misc.ts +0 -73
- package/src/new/types/redux.ts +0 -73
- package/src/new/types/rights.ts +0 -28
- package/src/new/utils/alias-generator.test.ts +0 -44
- package/src/new/utils/alias-generator.ts +0 -18
- package/src/new/utils/date-filter-params.ts +0 -28
- package/src/new/utils/endpoint.test.ts +0 -193
- package/src/new/utils/endpoint.ts +0 -62
- package/src/new/utils/event-map.ts +0 -11
- package/src/new/utils/format-utils.ts +0 -22
- package/src/new/utils/formatters.ts +0 -36
- package/src/new/utils/index.ts +0 -10
- package/src/new/utils/notifications.ts +0 -9
- package/src/new/utils/renderer.ts +0 -38
- package/src/new/utils/rights.ts +0 -66
- package/src/new/utils/sorter.ts +0 -19
- package/src/new/utils/tooltip.ts +0 -94
- package/src/new/utils/transformers.test.ts +0 -549
- package/src/new/utils/transformers.ts +0 -174
- package/src/new/utils/validators.test.ts +0 -165
- package/src/new/utils/validators.ts +0 -81
- package/src/old/assets/images/index.ts +0 -69
- package/src/old/components/create-edit/create-edit.styles.ts +0 -16
- package/src/old/components/create-edit/create-edit.template.ts +0 -15
- package/src/old/components/create-edit/create-edit.ts +0 -70
- package/src/old/components/create-edit/index.ts +0 -3
- package/src/old/components/list/columns.ts +0 -175
- package/src/old/components/list/index.ts +0 -3
- package/src/old/components/list/list.styles.ts +0 -9
- package/src/old/components/list/list.template.ts +0 -40
- package/src/old/components/list/list.ts +0 -109
- package/src/old/components/preview/columns.ts +0 -58
- package/src/old/components/preview/index.ts +0 -3
- package/src/old/components/preview/preview.styles.ts +0 -22
- package/src/old/components/preview/preview.template.ts +0 -33
- package/src/old/components/preview/preview.ts +0 -143
- package/src/old/components/rapid-components.ts +0 -64
- package/src/old/components/renderers/custom-header-component.ts +0 -92
- package/src/old/components/renderers/filter-value-renderer.ts +0 -237
- package/src/old/components/renderers/row-select.renderer.ts +0 -148
- package/src/old/components/select-fields/columns.ts +0 -83
- package/src/old/components/select-fields/data.ts +0 -218
- package/src/old/components/select-fields/index.ts +0 -3
- package/src/old/components/select-fields/select-fields.styles.ts +0 -22
- package/src/old/components/select-fields/select-fields.template.ts +0 -58
- package/src/old/components/select-fields/select-fields.ts +0 -218
- package/src/old/components/select-filters/columns.ts +0 -78
- package/src/old/components/select-filters/index.ts +0 -3
- package/src/old/components/select-filters/select-filters.styles.ts +0 -21
- package/src/old/components/select-filters/select-filters.template.ts +0 -58
- package/src/old/components/select-filters/select-filters.ts +0 -255
- package/src/old/components/wizard/debug.ts +0 -35
- package/src/old/components/wizard/index.ts +0 -2
- package/src/old/components/wizard/steps/filters.ts +0 -13
- package/src/old/components/wizard/steps/index.ts +0 -4
- package/src/old/components/wizard/steps/name.ts +0 -72
- package/src/old/components/wizard/steps/run.ts +0 -14
- package/src/old/components/wizard/steps/select.ts +0 -14
- package/src/old/components/wizard/wizard.styles.ts +0 -198
- package/src/old/components/wizard/wizard.template.ts +0 -147
- package/src/old/components/wizard/wizard.ts +0 -398
- package/src/old/components/wizard/wizard.types.ts +0 -43
- package/src/old/components/zero-components.ts +0 -61
- package/src/old/config/config.ts +0 -59
- package/src/old/config/configure.ts +0 -66
- package/src/old/config/index.ts +0 -2
- package/src/old/config/templates.ts +0 -59
- package/src/old/constants/grid-config.ts +0 -19
- package/src/old/layouts/default.ts +0 -30
- package/src/old/layouts/index.ts +0 -2
- package/src/old/layouts/two-pane-horizontal.ts +0 -81
- package/src/old/main/index.ts +0 -3
- package/src/old/main/main.styles.ts +0 -69
- package/src/old/main/main.template.ts +0 -127
- package/src/old/main/main.test.ts +0 -7
- package/src/old/main/main.ts +0 -250
- package/src/old/main/types.ts +0 -29
- package/src/old/styles/colors.ts +0 -16
- package/src/old/styles/helpers.ts +0 -181
- package/src/old/styles/index.ts +0 -4
- package/src/old/styles/normalize.ts +0 -14
- package/src/old/styles/styles.ts +0 -24
- package/src/old/tags/index.ts +0 -1
- package/src/old/tags/tags.ts +0 -79
- package/src/old/tsconfig.json +0 -10
- package/src/old/utils/filterObjectArray.test.ts +0 -110
- package/src/old/utils/filterObjectArray.ts +0 -23
- package/src/old/utils/getFiltersByType.ts +0 -92
- package/src/old/utils/getSelectedFields.ts +0 -16
- package/src/old/utils/index.ts +0 -4
- package/src/old/utils/logger.ts +0 -3
- package/src/sandbox.ts +0 -51
- package/src/tsconfig.base.json +0 -24
- package/src/typings.d.ts +0 -1
- package/tsconfig.json +0 -9
package/dist/esm/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.js
DELETED
|
@@ -1,629 +0,0 @@
|
|
|
1
|
-
import { assert, sinon, suite } from '@genesislcap/foundation-testing';
|
|
2
|
-
import { actions, selectors } from '../../../store';
|
|
3
|
-
import { GridColumnNames } from '../shared';
|
|
4
|
-
import { determineDateLocaleFormat, FormatToConfigTokens, getDateConfig, lookupColumnFormat, mapToDateFormat, transformFromFormatString, validateFormatString, valueExprCellRendereronChange, mapToNumberFormat, transformFromNumberFormatString, getDefaultFormat, } from './data-transforms.helpers';
|
|
5
|
-
import { DateLocaleFormats, DateMonthFormats, DateStandardFormats, DateTimeFormats, DateYearFormats, FormatTypes, NumericFormats, NumericCurrencies, isNumericFieldType, } from './data-transforms.types';
|
|
6
|
-
const LookupColumnFormat = suite('LookupColumnFormat()');
|
|
7
|
-
LookupColumnFormat.before.each(() => {
|
|
8
|
-
sinon.restore();
|
|
9
|
-
});
|
|
10
|
-
LookupColumnFormat('should return empty string when no format is found', () => {
|
|
11
|
-
const mockData = {
|
|
12
|
-
[GridColumnNames.ColumnName]: 'originalColumn',
|
|
13
|
-
[GridColumnNames.Format]: '',
|
|
14
|
-
[GridColumnNames.Type]: 'DATETIME',
|
|
15
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
16
|
-
};
|
|
17
|
-
const getDatasourceStub = sinon.stub(selectors.datasourceConfig, 'getDatasource').returns({
|
|
18
|
-
KEY: 'test',
|
|
19
|
-
NAME: 'Test Datasource',
|
|
20
|
-
INPUT_TYPE: 'REQ_REP',
|
|
21
|
-
OUTPUT_TYPE: 'TABLE',
|
|
22
|
-
TRANSFORMER_CONFIGURATION: { COLUMN_FORMATS: {} },
|
|
23
|
-
GROUPING_STRATEGY: 'NONE',
|
|
24
|
-
GROUP_KEY: null,
|
|
25
|
-
});
|
|
26
|
-
const result = lookupColumnFormat(mockData);
|
|
27
|
-
assert.equal(result[GridColumnNames.Format], ''); // No format found, returns empty string
|
|
28
|
-
assert.ok(getDatasourceStub.calledOnce);
|
|
29
|
-
});
|
|
30
|
-
LookupColumnFormat('should return data with format when format exists', () => {
|
|
31
|
-
const originalColumn = 'originalColumn';
|
|
32
|
-
const newFormat = 'dd/MM/yyyy';
|
|
33
|
-
const mockData = {
|
|
34
|
-
[GridColumnNames.ColumnName]: originalColumn,
|
|
35
|
-
[GridColumnNames.Format]: newFormat,
|
|
36
|
-
[GridColumnNames.Type]: 'STRING',
|
|
37
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
38
|
-
};
|
|
39
|
-
const getDatasourceStub = sinon.stub(selectors.datasourceConfig, 'getDatasource').returns({
|
|
40
|
-
KEY: 'test',
|
|
41
|
-
NAME: 'Test Datasource',
|
|
42
|
-
INPUT_TYPE: 'REQ_REP',
|
|
43
|
-
OUTPUT_TYPE: 'TABLE',
|
|
44
|
-
TRANSFORMER_CONFIGURATION: {
|
|
45
|
-
COLUMN_FORMATS: {
|
|
46
|
-
[originalColumn]: newFormat,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
GROUPING_STRATEGY: 'NONE',
|
|
50
|
-
GROUP_KEY: null,
|
|
51
|
-
});
|
|
52
|
-
const result = lookupColumnFormat(mockData);
|
|
53
|
-
assert.equal(result[GridColumnNames.Format], newFormat);
|
|
54
|
-
assert.equal(result[GridColumnNames.ColumnName], mockData[GridColumnNames.ColumnName]);
|
|
55
|
-
assert.equal(result[GridColumnNames.Type], mockData[GridColumnNames.Type]);
|
|
56
|
-
assert.equal(result[GridColumnNames.Datasource], mockData[GridColumnNames.Datasource]);
|
|
57
|
-
assert.ok(getDatasourceStub.calledOnce);
|
|
58
|
-
});
|
|
59
|
-
LookupColumnFormat('should handle undefined COLUMN_FORMATS', () => {
|
|
60
|
-
const mockData = {
|
|
61
|
-
[GridColumnNames.ColumnName]: 'originalColumn',
|
|
62
|
-
[GridColumnNames.Format]: '',
|
|
63
|
-
[GridColumnNames.Type]: 'STRING',
|
|
64
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
65
|
-
};
|
|
66
|
-
const getDatasourceStub = sinon.stub(selectors.datasourceConfig, 'getDatasource').returns({
|
|
67
|
-
KEY: 'test',
|
|
68
|
-
NAME: 'Test Datasource',
|
|
69
|
-
INPUT_TYPE: 'REQ_REP',
|
|
70
|
-
OUTPUT_TYPE: 'TABLE',
|
|
71
|
-
TRANSFORMER_CONFIGURATION: {},
|
|
72
|
-
GROUPING_STRATEGY: 'NONE',
|
|
73
|
-
GROUP_KEY: null,
|
|
74
|
-
});
|
|
75
|
-
const result = lookupColumnFormat(mockData);
|
|
76
|
-
assert.equal(result[GridColumnNames.Format], ''); // No format found, returns empty string
|
|
77
|
-
assert.ok(getDatasourceStub.calledOnce);
|
|
78
|
-
});
|
|
79
|
-
LookupColumnFormat('should return existing format when format exists', () => {
|
|
80
|
-
const mockData = {
|
|
81
|
-
[GridColumnNames.ColumnName]: 'numericColumn',
|
|
82
|
-
[GridColumnNames.Format]: '',
|
|
83
|
-
[GridColumnNames.Type]: 'DOUBLE',
|
|
84
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
85
|
-
};
|
|
86
|
-
const getDatasourceStub = sinon.stub(selectors.datasourceConfig, 'getDatasource').returns({
|
|
87
|
-
KEY: 'test',
|
|
88
|
-
NAME: 'Test Datasource',
|
|
89
|
-
INPUT_TYPE: 'REQ_REP',
|
|
90
|
-
OUTPUT_TYPE: 'TABLE',
|
|
91
|
-
TRANSFORMER_CONFIGURATION: {
|
|
92
|
-
COLUMN_FORMATS: {
|
|
93
|
-
numericColumn: '#.##',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
GROUPING_STRATEGY: 'NONE',
|
|
97
|
-
GROUP_KEY: null,
|
|
98
|
-
});
|
|
99
|
-
const result = lookupColumnFormat(mockData);
|
|
100
|
-
assert.equal(result[GridColumnNames.Format], '#.##'); // Existing format is returned
|
|
101
|
-
assert.ok(getDatasourceStub.calledOnce);
|
|
102
|
-
});
|
|
103
|
-
LookupColumnFormat.run();
|
|
104
|
-
const DetermineDateLocaleFormat = suite('DetermineDateLocaleFormat()');
|
|
105
|
-
DetermineDateLocaleFormat.before.each(() => {
|
|
106
|
-
sinon.restore();
|
|
107
|
-
});
|
|
108
|
-
DetermineDateLocaleFormat('should return unformatted for empty format string', () => {
|
|
109
|
-
const formatString = '';
|
|
110
|
-
assert.equal(determineDateLocaleFormat(formatString), DateLocaleFormats.Unformatted);
|
|
111
|
-
});
|
|
112
|
-
DetermineDateLocaleFormat('should return en-US for format string that contains hh, a, - or starts with month', () => {
|
|
113
|
-
assert.equal(determineDateLocaleFormat('MM-dd-yyyy'), DateLocaleFormats.US);
|
|
114
|
-
assert.equal(determineDateLocaleFormat('dd-MM-yyyy hh:mm:ss a'), DateLocaleFormats.US);
|
|
115
|
-
});
|
|
116
|
-
DetermineDateLocaleFormat('should return en-GB for format string that contains / or does not starts with month', () => {
|
|
117
|
-
assert.equal(determineDateLocaleFormat('dd/MM/yyyy'), DateLocaleFormats.UK);
|
|
118
|
-
});
|
|
119
|
-
DetermineDateLocaleFormat.run();
|
|
120
|
-
const GetDateConfig = suite('GetDateConfig()');
|
|
121
|
-
GetDateConfig.before.each(() => {
|
|
122
|
-
sinon.restore();
|
|
123
|
-
});
|
|
124
|
-
GetDateConfig('should return config with valid date time tokens', () => {
|
|
125
|
-
const formatString = 'd/MM/yyyy HH:mm:ss';
|
|
126
|
-
const mockData = {
|
|
127
|
-
hour: '2-digit',
|
|
128
|
-
minute: '2-digit',
|
|
129
|
-
second: '2-digit',
|
|
130
|
-
month: '2-digit',
|
|
131
|
-
day: 'numeric',
|
|
132
|
-
year: 'full',
|
|
133
|
-
};
|
|
134
|
-
assert.equal(getDateConfig(formatString), mockData);
|
|
135
|
-
});
|
|
136
|
-
GetDateConfig('should return config with valid date time tokens and skip invalid tokens(YY, DD)', () => {
|
|
137
|
-
const formatString = 'DD/MM/YY HH:mm:ss';
|
|
138
|
-
const mockData = {
|
|
139
|
-
hour: '2-digit',
|
|
140
|
-
minute: '2-digit',
|
|
141
|
-
second: '2-digit',
|
|
142
|
-
month: '2-digit',
|
|
143
|
-
};
|
|
144
|
-
assert.equal(getDateConfig(formatString), mockData);
|
|
145
|
-
});
|
|
146
|
-
GetDateConfig.run();
|
|
147
|
-
const ValidateFormatString = suite('validateFormatString()');
|
|
148
|
-
ValidateFormatString.before.each(() => {
|
|
149
|
-
sinon.restore();
|
|
150
|
-
});
|
|
151
|
-
ValidateFormatString('should return empty list for valid format string', () => {
|
|
152
|
-
const formatString = 'dd/MM/yyyy HH:mm:ss';
|
|
153
|
-
assert.equal(validateFormatString(formatString).length, 0);
|
|
154
|
-
});
|
|
155
|
-
ValidateFormatString('should return config with valid date time tokens and skip invalid tokens(YY, DD)', () => {
|
|
156
|
-
const formatString = 'DD/MM/YY HH:mm:ss';
|
|
157
|
-
assert.equal(validateFormatString(formatString).length, 2);
|
|
158
|
-
});
|
|
159
|
-
ValidateFormatString.run();
|
|
160
|
-
const MapToDateFormat = suite('MapToDateFormat()');
|
|
161
|
-
MapToDateFormat.before.each(() => {
|
|
162
|
-
sinon.restore();
|
|
163
|
-
});
|
|
164
|
-
MapToDateFormat('should return format string for uk according to input data', () => {
|
|
165
|
-
const mockData = {
|
|
166
|
-
[GridColumnNames.ColumnName]: 'originalColumn',
|
|
167
|
-
[GridColumnNames.Format]: '',
|
|
168
|
-
[GridColumnNames.Type]: 'DATETIME',
|
|
169
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
170
|
-
type: FormatTypes.Datetime,
|
|
171
|
-
format: DateLocaleFormats.UK,
|
|
172
|
-
year: DateYearFormats.Full,
|
|
173
|
-
month: DateMonthFormats.Digit,
|
|
174
|
-
day: DateStandardFormats.Digit,
|
|
175
|
-
hour: DateTimeFormats.Show,
|
|
176
|
-
minute: DateTimeFormats.Show,
|
|
177
|
-
second: DateTimeFormats.Show,
|
|
178
|
-
};
|
|
179
|
-
const formatString = 'dd/MM/yyyy HH:mm:ss';
|
|
180
|
-
assert.equal(mapToDateFormat(mockData), formatString);
|
|
181
|
-
});
|
|
182
|
-
MapToDateFormat('should return format string for US with 12 hr format and am/pm indicator', () => {
|
|
183
|
-
const mockData = {
|
|
184
|
-
[GridColumnNames.ColumnName]: 'originalColumn',
|
|
185
|
-
[GridColumnNames.Format]: '',
|
|
186
|
-
[GridColumnNames.Type]: 'DATETIME',
|
|
187
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
188
|
-
type: FormatTypes.Datetime,
|
|
189
|
-
format: DateLocaleFormats.US,
|
|
190
|
-
year: DateYearFormats.Full,
|
|
191
|
-
month: DateMonthFormats.Digit,
|
|
192
|
-
day: DateStandardFormats.Digit,
|
|
193
|
-
hour: DateTimeFormats.Show,
|
|
194
|
-
minute: DateTimeFormats.Show,
|
|
195
|
-
second: DateTimeFormats.Show,
|
|
196
|
-
};
|
|
197
|
-
const formatString = 'MM-dd-yyyy hh:mm:ss a';
|
|
198
|
-
assert.equal(mapToDateFormat(mockData), formatString);
|
|
199
|
-
});
|
|
200
|
-
MapToDateFormat('should return format string with only date parts when time parts are hidden ', () => {
|
|
201
|
-
const mockData = {
|
|
202
|
-
[GridColumnNames.ColumnName]: 'originalColumn',
|
|
203
|
-
[GridColumnNames.Format]: '',
|
|
204
|
-
[GridColumnNames.Type]: 'DATETIME',
|
|
205
|
-
[GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
206
|
-
type: FormatTypes.Datetime,
|
|
207
|
-
format: DateLocaleFormats.US,
|
|
208
|
-
year: DateYearFormats.Full,
|
|
209
|
-
month: DateMonthFormats.Digit,
|
|
210
|
-
day: DateStandardFormats.Digit,
|
|
211
|
-
hour: DateTimeFormats.Hide,
|
|
212
|
-
minute: DateTimeFormats.Hide,
|
|
213
|
-
second: DateTimeFormats.Hide,
|
|
214
|
-
};
|
|
215
|
-
const formatString = 'MM-dd-yyyy';
|
|
216
|
-
assert.equal(mapToDateFormat(mockData), formatString);
|
|
217
|
-
});
|
|
218
|
-
MapToDateFormat.run();
|
|
219
|
-
const TransformFromFormatString = suite('TransformFromFormatString()');
|
|
220
|
-
TransformFromFormatString.before.each(() => {
|
|
221
|
-
sinon.restore();
|
|
222
|
-
});
|
|
223
|
-
TransformFromFormatString('should return config with format en-GB for dd/MM/yyyy HH:mm:ss', () => {
|
|
224
|
-
const mockData = {
|
|
225
|
-
type: FormatTypes.Datetime,
|
|
226
|
-
format: DateLocaleFormats.UK,
|
|
227
|
-
year: DateYearFormats.Full,
|
|
228
|
-
month: DateMonthFormats.Digit,
|
|
229
|
-
day: DateStandardFormats.Digit,
|
|
230
|
-
hour: DateTimeFormats.Show,
|
|
231
|
-
minute: DateTimeFormats.Show,
|
|
232
|
-
second: DateTimeFormats.Show,
|
|
233
|
-
};
|
|
234
|
-
const formatString = 'dd/MM/yyyy HH:mm:ss';
|
|
235
|
-
const result = transformFromFormatString(formatString, mockData.type);
|
|
236
|
-
assert.equal(result, mockData);
|
|
237
|
-
});
|
|
238
|
-
TransformFromFormatString('should return config with format en-GB for dd/MM/yyyy and hide in time tokens', () => {
|
|
239
|
-
const mockData = {
|
|
240
|
-
type: FormatTypes.Datetime,
|
|
241
|
-
format: DateLocaleFormats.UK,
|
|
242
|
-
year: DateYearFormats.Full,
|
|
243
|
-
month: DateMonthFormats.Digit,
|
|
244
|
-
day: DateStandardFormats.Digit,
|
|
245
|
-
hour: DateTimeFormats.Hide,
|
|
246
|
-
minute: DateTimeFormats.Hide,
|
|
247
|
-
second: DateTimeFormats.Hide,
|
|
248
|
-
};
|
|
249
|
-
const formatString = 'dd/MM/yyyy';
|
|
250
|
-
const result = transformFromFormatString(formatString, mockData.type);
|
|
251
|
-
assert.equal(result, mockData);
|
|
252
|
-
});
|
|
253
|
-
TransformFromFormatString('should return config with format en-GB for dd/MM/yyyy HH:mm:ss', () => {
|
|
254
|
-
const mockData = {
|
|
255
|
-
type: FormatTypes.Datetime,
|
|
256
|
-
format: DateLocaleFormats.UK,
|
|
257
|
-
year: DateYearFormats.Full,
|
|
258
|
-
month: DateMonthFormats.Digit,
|
|
259
|
-
day: DateStandardFormats.Digit,
|
|
260
|
-
hour: DateTimeFormats.Show,
|
|
261
|
-
minute: DateTimeFormats.Show,
|
|
262
|
-
second: DateTimeFormats.Show,
|
|
263
|
-
};
|
|
264
|
-
const formatString = 'dd/MM/yyyy HH:mm:ss';
|
|
265
|
-
const result = transformFromFormatString(formatString, mockData.type);
|
|
266
|
-
assert.equal(result, mockData);
|
|
267
|
-
});
|
|
268
|
-
TransformFromFormatString('should return config with format en-GB for dd/MM/yyyy and without time token for Date type column ', () => {
|
|
269
|
-
const mockData = {
|
|
270
|
-
type: FormatTypes.Date,
|
|
271
|
-
format: DateLocaleFormats.UK,
|
|
272
|
-
year: DateYearFormats.Full,
|
|
273
|
-
month: DateMonthFormats.Digit,
|
|
274
|
-
day: DateStandardFormats.Digit,
|
|
275
|
-
};
|
|
276
|
-
const formatString = 'dd/MM/yyyy';
|
|
277
|
-
const result = transformFromFormatString(formatString, mockData.type);
|
|
278
|
-
assert.equal(result, mockData);
|
|
279
|
-
});
|
|
280
|
-
TransformFromFormatString.run();
|
|
281
|
-
const FormatToConfigTokensSuite = suite('FormatToConfigTokens()');
|
|
282
|
-
FormatToConfigTokensSuite.before.each(() => {
|
|
283
|
-
sinon.restore();
|
|
284
|
-
});
|
|
285
|
-
FormatToConfigTokensSuite('should return object with field value for date format tokens', () => {
|
|
286
|
-
assert.equal(FormatToConfigTokens['HH'], { field: 'hour', value: DateTimeFormats.Show });
|
|
287
|
-
assert.equal(FormatToConfigTokens['hh'], { field: 'hour', value: DateTimeFormats.Show });
|
|
288
|
-
assert.equal(FormatToConfigTokens['yy'], { field: 'year', value: DateYearFormats.Digit });
|
|
289
|
-
assert.equal(FormatToConfigTokens['M'], { field: 'month', value: DateMonthFormats.Numeric });
|
|
290
|
-
});
|
|
291
|
-
FormatToConfigTokensSuite.run();
|
|
292
|
-
// Test for lookupDataTransform function
|
|
293
|
-
// const LookupDataTransform = suite('lookupDataTransform()');
|
|
294
|
-
// LookupDataTransform.before.each(() => {
|
|
295
|
-
// sinon.restore();
|
|
296
|
-
// });
|
|
297
|
-
// LookupDataTransform('should return data with added transform when transform exists', () => {
|
|
298
|
-
// const mockExpressionBuilderFields: ExpressionBuilderTypes.Field[] = [
|
|
299
|
-
// {
|
|
300
|
-
// fieldId: 'field1',
|
|
301
|
-
// label: 'Field 1',
|
|
302
|
-
// type: 'string',
|
|
303
|
-
// input: 'text',
|
|
304
|
-
// },
|
|
305
|
-
// {
|
|
306
|
-
// fieldId: 'field2',
|
|
307
|
-
// label: 'Field 2',
|
|
308
|
-
// type: 'double',
|
|
309
|
-
// input: 'number',
|
|
310
|
-
// },
|
|
311
|
-
// ];
|
|
312
|
-
// const mockData: DataTransformData = {
|
|
313
|
-
// [GridColumnNames.ColumnName]: 'testColumn',
|
|
314
|
-
// [GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
315
|
-
// [GridColumnNames.Type]: 'STRING',
|
|
316
|
-
// };
|
|
317
|
-
// // Using a specific allowed method type
|
|
318
|
-
// const mockExpression = {
|
|
319
|
-
// METHOD: 'TRIM' as const,
|
|
320
|
-
// TYPE: 'METHOD_EXPRESSION' as const,
|
|
321
|
-
// PARAMETERS: [
|
|
322
|
-
// {
|
|
323
|
-
// TYPE: 'FIELD' as const,
|
|
324
|
-
// NAME: 'field1',
|
|
325
|
-
// },
|
|
326
|
-
// ],
|
|
327
|
-
// };
|
|
328
|
-
// const getRowTransformStub = sinon
|
|
329
|
-
// .stub(selectors.datasourceConfig, 'getRowTransform')
|
|
330
|
-
// .returns(mockExpression);
|
|
331
|
-
// const result = lookupDataTransform(mockExpressionBuilderFields)(mockData);
|
|
332
|
-
// assert.ok(getRowTransformStub.calledOnce);
|
|
333
|
-
// assert.equal(getRowTransformStub.firstCall.args[0], 'REQ_REP_Test');
|
|
334
|
-
// assert.equal(getRowTransformStub.firstCall.args[1], 'testColumn');
|
|
335
|
-
// assert.equal(result[GridColumnNames.ColumnName], mockData[GridColumnNames.ColumnName]);
|
|
336
|
-
// assert.equal(result[GridColumnNames.Datasource], mockData[GridColumnNames.Datasource]);
|
|
337
|
-
// assert.equal(result[GridColumnNames.Type], mockData[GridColumnNames.Type]);
|
|
338
|
-
// const transformResult = result[GridColumnNames.DataTransform];
|
|
339
|
-
// assert.equal(transformResult!.fields, mockExpressionBuilderFields);
|
|
340
|
-
// assert.equal(transformResult!.model, mockExpression);
|
|
341
|
-
// assert.equal(transformResult!.partialRuleValidationWarning, true);
|
|
342
|
-
// });
|
|
343
|
-
// LookupDataTransform('should return data with empty model when no transform exists', () => {
|
|
344
|
-
// const mockExpressionBuilderFields: ExpressionBuilderTypes.Field[] = [
|
|
345
|
-
// {
|
|
346
|
-
// fieldId: 'field1',
|
|
347
|
-
// label: 'Field 1',
|
|
348
|
-
// type: 'string',
|
|
349
|
-
// input: 'text',
|
|
350
|
-
// },
|
|
351
|
-
// ];
|
|
352
|
-
// const mockData: DataTransformData = {
|
|
353
|
-
// [GridColumnNames.ColumnName]: 'testColumn',
|
|
354
|
-
// [GridColumnNames.Datasource]: 'Test (Snapshot)',
|
|
355
|
-
// [GridColumnNames.Type]: 'STRING',
|
|
356
|
-
// };
|
|
357
|
-
// const getRowTransformStub = sinon
|
|
358
|
-
// .stub(selectors.datasourceConfig, 'getRowTransform')
|
|
359
|
-
// .returns(undefined);
|
|
360
|
-
// const result = lookupDataTransform(mockExpressionBuilderFields)(mockData);
|
|
361
|
-
// assert.ok(getRowTransformStub.calledOnce);
|
|
362
|
-
// const transformResult = result[GridColumnNames.DataTransform];
|
|
363
|
-
// assert.equal(transformResult!.fields, mockExpressionBuilderFields);
|
|
364
|
-
// assert.equal(transformResult!.model, undefined);
|
|
365
|
-
// assert.equal(transformResult!.partialRuleValidationWarning, true);
|
|
366
|
-
// });
|
|
367
|
-
// LookupDataTransform.run();
|
|
368
|
-
// Test for valueExprCellRendereronChange function
|
|
369
|
-
const ValueExprCellRendereronChange = suite('valueExprCellRendereronChange()');
|
|
370
|
-
ValueExprCellRendereronChange.before.each(() => {
|
|
371
|
-
sinon.restore();
|
|
372
|
-
});
|
|
373
|
-
ValueExprCellRendereronChange('should call setColumnTransform when model exists', () => {
|
|
374
|
-
const datasourceKey = 'REQ_REP_RESOURCE_ALIAS';
|
|
375
|
-
const columnName = 'testColumn';
|
|
376
|
-
// Using type assertions to match the expected type
|
|
377
|
-
const mockExpression = {
|
|
378
|
-
METHOD: 'TRIM',
|
|
379
|
-
TYPE: 'METHOD_EXPRESSION',
|
|
380
|
-
PARAMETERS: [
|
|
381
|
-
{
|
|
382
|
-
TYPE: 'FIELD',
|
|
383
|
-
NAME: 'field1',
|
|
384
|
-
},
|
|
385
|
-
],
|
|
386
|
-
};
|
|
387
|
-
const mockParams = {
|
|
388
|
-
data: {
|
|
389
|
-
[GridColumnNames.ColumnName]: columnName,
|
|
390
|
-
},
|
|
391
|
-
};
|
|
392
|
-
const setColumnTransformStub = sinon.stub(actions.datasourceConfig, 'setColumnTransform');
|
|
393
|
-
const deleteColumnTransformStub = sinon.stub(actions.datasourceConfig, 'deleteColumnTransform');
|
|
394
|
-
const onChange = valueExprCellRendereronChange(datasourceKey);
|
|
395
|
-
onChange({
|
|
396
|
-
fields: [
|
|
397
|
-
{
|
|
398
|
-
fieldId: 'field1',
|
|
399
|
-
label: 'Field 1',
|
|
400
|
-
type: 'string',
|
|
401
|
-
input: 'text',
|
|
402
|
-
},
|
|
403
|
-
],
|
|
404
|
-
model: mockExpression,
|
|
405
|
-
partialRuleValidationWarning: true,
|
|
406
|
-
}, mockParams);
|
|
407
|
-
assert.ok(setColumnTransformStub.calledOnce);
|
|
408
|
-
assert.equal(setColumnTransformStub.firstCall.args[0].key, datasourceKey);
|
|
409
|
-
assert.equal(setColumnTransformStub.firstCall.args[0].column, columnName);
|
|
410
|
-
assert.equal(setColumnTransformStub.firstCall.args[0].expression, mockExpression);
|
|
411
|
-
assert.equal(deleteColumnTransformStub.called, false);
|
|
412
|
-
});
|
|
413
|
-
ValueExprCellRendereronChange('should call deleteColumnTransform when model is null', () => {
|
|
414
|
-
const datasourceKey = 'REQ_REP_RESOURCE_ALIAS';
|
|
415
|
-
const columnName = 'testColumn';
|
|
416
|
-
const mockParams = {
|
|
417
|
-
data: {
|
|
418
|
-
[GridColumnNames.ColumnName]: columnName,
|
|
419
|
-
},
|
|
420
|
-
};
|
|
421
|
-
const setColumnTransformStub = sinon.stub(actions.datasourceConfig, 'setColumnTransform');
|
|
422
|
-
const deleteColumnTransformStub = sinon.stub(actions.datasourceConfig, 'deleteColumnTransform');
|
|
423
|
-
const onChange = valueExprCellRendereronChange(datasourceKey);
|
|
424
|
-
onChange({
|
|
425
|
-
fields: [
|
|
426
|
-
{
|
|
427
|
-
fieldId: 'field1',
|
|
428
|
-
label: 'Field 1',
|
|
429
|
-
type: 'string',
|
|
430
|
-
input: 'text',
|
|
431
|
-
},
|
|
432
|
-
],
|
|
433
|
-
model: null,
|
|
434
|
-
partialRuleValidationWarning: true,
|
|
435
|
-
}, mockParams);
|
|
436
|
-
assert.equal(setColumnTransformStub.called, false);
|
|
437
|
-
assert.ok(deleteColumnTransformStub.calledOnce);
|
|
438
|
-
assert.equal(deleteColumnTransformStub.firstCall.args[0].key, datasourceKey);
|
|
439
|
-
assert.equal(deleteColumnTransformStub.firstCall.args[0].column, columnName);
|
|
440
|
-
});
|
|
441
|
-
ValueExprCellRendereronChange.run();
|
|
442
|
-
const MapToNumberFormat = suite('MapToNumberFormat()');
|
|
443
|
-
MapToNumberFormat.before.each(() => {
|
|
444
|
-
sinon.restore();
|
|
445
|
-
});
|
|
446
|
-
MapToNumberFormat('should create financial format with no decimal places by default', () => {
|
|
447
|
-
const result = mapToNumberFormat(NumericFormats.Financial);
|
|
448
|
-
assert.equal(result, '#,##0');
|
|
449
|
-
});
|
|
450
|
-
MapToNumberFormat('should create financial format with specified decimal places', () => {
|
|
451
|
-
const result = mapToNumberFormat(NumericFormats.Financial, 3);
|
|
452
|
-
assert.equal(result, '#,##0.###');
|
|
453
|
-
});
|
|
454
|
-
MapToNumberFormat('should create financial format with 0 decimal places', () => {
|
|
455
|
-
const result = mapToNumberFormat(NumericFormats.Financial, 0);
|
|
456
|
-
assert.equal(result, '#,##0');
|
|
457
|
-
});
|
|
458
|
-
MapToNumberFormat('should create simple decimal format with no decimal places by default', () => {
|
|
459
|
-
const result = mapToNumberFormat(NumericFormats.SimpleDecimal);
|
|
460
|
-
assert.equal(result, '#');
|
|
461
|
-
});
|
|
462
|
-
MapToNumberFormat('should create simple decimal format with specified decimal places', () => {
|
|
463
|
-
const result = mapToNumberFormat(NumericFormats.SimpleDecimal, 3);
|
|
464
|
-
assert.equal(result, '#.###');
|
|
465
|
-
});
|
|
466
|
-
MapToNumberFormat('should create simple decimal format with 0 decimal places', () => {
|
|
467
|
-
const result = mapToNumberFormat(NumericFormats.SimpleDecimal, 0);
|
|
468
|
-
assert.equal(result, '#');
|
|
469
|
-
});
|
|
470
|
-
MapToNumberFormat('should create percent format with no decimal places by default', () => {
|
|
471
|
-
const result = mapToNumberFormat(NumericFormats.Percent);
|
|
472
|
-
assert.equal(result, '##%');
|
|
473
|
-
});
|
|
474
|
-
MapToNumberFormat('should create percent format with specified decimal places', () => {
|
|
475
|
-
const result = mapToNumberFormat(NumericFormats.Percent, 1);
|
|
476
|
-
assert.equal(result, '##.#%');
|
|
477
|
-
});
|
|
478
|
-
MapToNumberFormat('should create currency format with US dollar symbol', () => {
|
|
479
|
-
const result = mapToNumberFormat(NumericFormats.Currency, 2, NumericCurrencies.US);
|
|
480
|
-
assert.equal(result, '$#,##0.##');
|
|
481
|
-
});
|
|
482
|
-
MapToNumberFormat('should create currency format with UK pound symbol', () => {
|
|
483
|
-
const result = mapToNumberFormat(NumericFormats.Currency, 2, NumericCurrencies.UK);
|
|
484
|
-
assert.equal(result, '£#,##0.##');
|
|
485
|
-
});
|
|
486
|
-
MapToNumberFormat('should create currency format with Euro symbol', () => {
|
|
487
|
-
const result = mapToNumberFormat(NumericFormats.Currency, 2, NumericCurrencies.EU);
|
|
488
|
-
assert.equal(result, '€#,##0.##');
|
|
489
|
-
});
|
|
490
|
-
MapToNumberFormat('should create currency format with Chinese Yuan symbol', () => {
|
|
491
|
-
const result = mapToNumberFormat(NumericFormats.Currency, 2, NumericCurrencies.CN);
|
|
492
|
-
assert.equal(result, '¥#,##0.##');
|
|
493
|
-
});
|
|
494
|
-
MapToNumberFormat('should default to US dollar when no currency specified', () => {
|
|
495
|
-
const result = mapToNumberFormat(NumericFormats.Currency, 2);
|
|
496
|
-
assert.equal(result, '$#,##0.##');
|
|
497
|
-
});
|
|
498
|
-
MapToNumberFormat('should create currency rounded format with US dollar symbol', () => {
|
|
499
|
-
const result = mapToNumberFormat(NumericFormats.CurrencyRounded, undefined, NumericCurrencies.US);
|
|
500
|
-
assert.equal(result, '$#,##0');
|
|
501
|
-
});
|
|
502
|
-
MapToNumberFormat('should create currency rounded format with UK pound symbol', () => {
|
|
503
|
-
const result = mapToNumberFormat(NumericFormats.CurrencyRounded, undefined, NumericCurrencies.UK);
|
|
504
|
-
assert.equal(result, '£#,##0');
|
|
505
|
-
});
|
|
506
|
-
MapToNumberFormat('should return empty string for unformatted', () => {
|
|
507
|
-
const result = mapToNumberFormat(NumericFormats.Unformatted);
|
|
508
|
-
assert.equal(result, '');
|
|
509
|
-
});
|
|
510
|
-
MapToNumberFormat.run();
|
|
511
|
-
const IsNumericFieldType = suite('IsNumericFieldType()');
|
|
512
|
-
IsNumericFieldType.before.each(() => {
|
|
513
|
-
sinon.restore();
|
|
514
|
-
});
|
|
515
|
-
IsNumericFieldType('should return true for numeric field types', () => {
|
|
516
|
-
assert.equal(isNumericFieldType('DOUBLE'), true);
|
|
517
|
-
assert.equal(isNumericFieldType('BIGDECIMAL'), true);
|
|
518
|
-
assert.equal(isNumericFieldType('INT'), true);
|
|
519
|
-
assert.equal(isNumericFieldType('SHORT'), true);
|
|
520
|
-
assert.equal(isNumericFieldType('LONG'), true);
|
|
521
|
-
});
|
|
522
|
-
IsNumericFieldType('should return false for non-numeric field types', () => {
|
|
523
|
-
assert.equal(isNumericFieldType('STRING'), false);
|
|
524
|
-
assert.equal(isNumericFieldType('DATE'), false);
|
|
525
|
-
assert.equal(isNumericFieldType('DATETIME'), false);
|
|
526
|
-
assert.equal(isNumericFieldType('BOOLEAN'), false);
|
|
527
|
-
assert.equal(isNumericFieldType('ENUM'), false);
|
|
528
|
-
});
|
|
529
|
-
IsNumericFieldType.run();
|
|
530
|
-
const TransformFromNumberFormatString = suite('TransformFromNumberFormatString()');
|
|
531
|
-
TransformFromNumberFormatString.before.each(() => {
|
|
532
|
-
sinon.restore();
|
|
533
|
-
});
|
|
534
|
-
TransformFromNumberFormatString('should return unformatted for empty format string', () => {
|
|
535
|
-
const result = transformFromNumberFormatString('', FormatTypes.Double);
|
|
536
|
-
assert.equal(result.type, FormatTypes.Double);
|
|
537
|
-
assert.equal(result.format, NumericFormats.Unformatted);
|
|
538
|
-
});
|
|
539
|
-
TransformFromNumberFormatString('should parse financial format', () => {
|
|
540
|
-
const result = transformFromNumberFormatString('#,##0.##', FormatTypes.Double);
|
|
541
|
-
assert.equal(result.type, FormatTypes.Double);
|
|
542
|
-
assert.equal(result.format, NumericFormats.Financial);
|
|
543
|
-
const numericResult = result;
|
|
544
|
-
assert.equal(numericResult.decimalPlaces, 2);
|
|
545
|
-
});
|
|
546
|
-
TransformFromNumberFormatString('should parse simple decimal format with decimal places', () => {
|
|
547
|
-
const result = transformFromNumberFormatString('#.##', FormatTypes.Double);
|
|
548
|
-
assert.equal(result.type, FormatTypes.Double);
|
|
549
|
-
assert.equal(result.format, NumericFormats.SimpleDecimal);
|
|
550
|
-
const numericResult = result;
|
|
551
|
-
assert.equal(numericResult.decimalPlaces, 2);
|
|
552
|
-
});
|
|
553
|
-
TransformFromNumberFormatString('should parse simple decimal format without decimal places', () => {
|
|
554
|
-
const result = transformFromNumberFormatString('#', FormatTypes.Double);
|
|
555
|
-
assert.equal(result.type, FormatTypes.Double);
|
|
556
|
-
assert.equal(result.format, NumericFormats.SimpleDecimal);
|
|
557
|
-
const numericResult = result;
|
|
558
|
-
assert.equal(numericResult.decimalPlaces, undefined);
|
|
559
|
-
});
|
|
560
|
-
TransformFromNumberFormatString('should parse percent format', () => {
|
|
561
|
-
const result = transformFromNumberFormatString('##.##%', FormatTypes.Double);
|
|
562
|
-
assert.equal(result.type, FormatTypes.Double);
|
|
563
|
-
assert.equal(result.format, NumericFormats.Percent);
|
|
564
|
-
const numericResult = result;
|
|
565
|
-
assert.equal(numericResult.decimalPlaces, 2);
|
|
566
|
-
});
|
|
567
|
-
TransformFromNumberFormatString('should parse currency format with US dollar', () => {
|
|
568
|
-
const result = transformFromNumberFormatString('$#,##0.##', FormatTypes.Double);
|
|
569
|
-
assert.equal(result.type, FormatTypes.Double);
|
|
570
|
-
assert.equal(result.format, NumericFormats.Currency);
|
|
571
|
-
const numericResult = result;
|
|
572
|
-
assert.equal(numericResult.currency, NumericCurrencies.US);
|
|
573
|
-
assert.equal(numericResult.decimalPlaces, 2);
|
|
574
|
-
});
|
|
575
|
-
TransformFromNumberFormatString('should parse currency format with UK pound', () => {
|
|
576
|
-
const result = transformFromNumberFormatString('£#,##0.##', FormatTypes.Double);
|
|
577
|
-
assert.equal(result.type, FormatTypes.Double);
|
|
578
|
-
assert.equal(result.format, NumericFormats.Currency);
|
|
579
|
-
const numericResult = result;
|
|
580
|
-
assert.equal(numericResult.currency, NumericCurrencies.UK);
|
|
581
|
-
assert.equal(numericResult.decimalPlaces, 2);
|
|
582
|
-
});
|
|
583
|
-
TransformFromNumberFormatString('should parse currency rounded format', () => {
|
|
584
|
-
const result = transformFromNumberFormatString('$#,##0', FormatTypes.Double);
|
|
585
|
-
assert.equal(result.type, FormatTypes.Double);
|
|
586
|
-
assert.equal(result.format, NumericFormats.CurrencyRounded);
|
|
587
|
-
const numericResult = result;
|
|
588
|
-
assert.equal(numericResult.currency, NumericCurrencies.US);
|
|
589
|
-
assert.equal(numericResult.decimalPlaces, undefined);
|
|
590
|
-
});
|
|
591
|
-
TransformFromNumberFormatString.run();
|
|
592
|
-
const GetDefaultFormat = suite('GetDefaultFormat()');
|
|
593
|
-
GetDefaultFormat.before.each(() => {
|
|
594
|
-
sinon.restore();
|
|
595
|
-
});
|
|
596
|
-
GetDefaultFormat('should return #.## for BIGDECIMAL type', () => {
|
|
597
|
-
const result = getDefaultFormat('BIGDECIMAL');
|
|
598
|
-
assert.equal(result, '#.##');
|
|
599
|
-
});
|
|
600
|
-
GetDefaultFormat('should return #.## for DOUBLE type', () => {
|
|
601
|
-
const result = getDefaultFormat('DOUBLE');
|
|
602
|
-
assert.equal(result, '#.##');
|
|
603
|
-
});
|
|
604
|
-
GetDefaultFormat('should return # for INT type', () => {
|
|
605
|
-
const result = getDefaultFormat('INT');
|
|
606
|
-
assert.equal(result, '#');
|
|
607
|
-
});
|
|
608
|
-
GetDefaultFormat('should return # for SHORT type', () => {
|
|
609
|
-
const result = getDefaultFormat('SHORT');
|
|
610
|
-
assert.equal(result, '#');
|
|
611
|
-
});
|
|
612
|
-
GetDefaultFormat('should return # for LONG type', () => {
|
|
613
|
-
const result = getDefaultFormat('LONG');
|
|
614
|
-
assert.equal(result, '#');
|
|
615
|
-
});
|
|
616
|
-
GetDefaultFormat('should return dd/MM/yyyy for DATE type', () => {
|
|
617
|
-
const result = getDefaultFormat('DATE');
|
|
618
|
-
assert.equal(result, 'dd/MM/yyyy');
|
|
619
|
-
});
|
|
620
|
-
GetDefaultFormat('should return dd/MM/yyyy HH:mm:ss for DATETIME type', () => {
|
|
621
|
-
const result = getDefaultFormat('DATETIME');
|
|
622
|
-
assert.equal(result, 'dd/MM/yyyy HH:mm:ss');
|
|
623
|
-
});
|
|
624
|
-
GetDefaultFormat('should return empty string for non-numeric and non-date types', () => {
|
|
625
|
-
assert.equal(getDefaultFormat('STRING'), '');
|
|
626
|
-
assert.equal(getDefaultFormat('BOOLEAN'), '');
|
|
627
|
-
assert.equal(getDefaultFormat('ENUM'), '');
|
|
628
|
-
});
|
|
629
|
-
GetDefaultFormat.run();
|