@jsonforms/core 3.1.0-alpha.0 → 3.1.0-alpha.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/lib/Helpers.d.ts +1 -1
- package/lib/actions/actions.d.ts +6 -5
- package/lib/generators/Generate.d.ts +1 -1
- package/lib/generators/schema.d.ts +1 -1
- package/lib/i18n/i18nTypes.d.ts +3 -2
- package/lib/i18n/i18nUtil.d.ts +2 -2
- package/lib/jsonforms-core.cjs.js +3 -3
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +2 -2
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/models/jsonSchema.d.ts +2 -2
- package/lib/models/uischema.d.ts +1 -1
- package/lib/reducers/cells.d.ts +2 -2
- package/lib/reducers/config.d.ts +1 -1
- package/lib/reducers/core.d.ts +3 -2
- package/lib/reducers/default-data.d.ts +1 -1
- package/lib/reducers/i18n.d.ts +1 -1
- package/lib/reducers/reducers.d.ts +4 -4
- package/lib/reducers/renderers.d.ts +2 -2
- package/lib/reducers/selectors.d.ts +6 -6
- package/lib/reducers/uischemas.d.ts +2 -2
- package/lib/store.d.ts +3 -3
- package/lib/testers/testers.d.ts +1 -1
- package/lib/util/cell.d.ts +3 -3
- package/lib/util/combinators.d.ts +1 -1
- package/lib/util/label.d.ts +1 -1
- package/lib/util/path.d.ts +6 -3
- package/lib/util/renderer.d.ts +5 -5
- package/lib/util/resolvers.d.ts +1 -1
- package/lib/util/runtime.d.ts +2 -2
- package/lib/util/util.d.ts +2 -2
- package/lib/util/validator.d.ts +1 -1
- package/package.json +7 -3
- package/src/Helpers.ts +1 -1
- package/src/actions/actions.ts +6 -5
- package/src/generators/Generate.ts +1 -1
- package/src/generators/schema.ts +1 -1
- package/src/i18n/i18nTypes.ts +3 -2
- package/src/i18n/i18nUtil.ts +2 -2
- package/src/models/jsonSchema.ts +2 -2
- package/src/models/uischema.ts +1 -1
- package/src/reducers/cells.ts +2 -2
- package/src/reducers/config.ts +1 -1
- package/src/reducers/core.ts +4 -3
- package/src/reducers/default-data.ts +1 -1
- package/src/reducers/i18n.ts +1 -1
- package/src/reducers/reducers.ts +4 -4
- package/src/reducers/renderers.ts +2 -2
- package/src/reducers/selectors.ts +6 -6
- package/src/reducers/uischemas.ts +2 -2
- package/src/store.ts +3 -3
- package/src/testers/testers.ts +2 -2
- package/src/util/cell.ts +3 -3
- package/src/util/combinators.ts +1 -1
- package/src/util/label.ts +1 -1
- package/src/util/path.ts +6 -3
- package/src/util/renderer.ts +5 -5
- package/src/util/resolvers.ts +2 -2
- package/src/util/runtime.ts +2 -2
- package/src/util/util.ts +2 -2
- package/src/util/validator.ts +1 -1
- package/.nycrc +0 -6
- package/docs/assets/css/main.css +0 -1
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -51
- package/docs/assets/js/search.json +0 -1
- package/docs/classes/gen.html +0 -406
- package/docs/enums/ruleeffect.html +0 -214
- package/docs/globals.html +0 -10568
- package/docs/index.html +0 -1297
- package/docs/interfaces/action.html +0 -166
- package/docs/interfaces/addcellrendereraction.html +0 -181
- package/docs/interfaces/addrendereraction.html +0 -181
- package/docs/interfaces/adduischemaaction.html +0 -181
- package/docs/interfaces/andcondition.html +0 -181
- package/docs/interfaces/anyaction.html +0 -189
- package/docs/interfaces/arraycontrolprops.html +0 -653
- package/docs/interfaces/arraylayoutprops.html +0 -648
- package/docs/interfaces/categorization.html +0 -281
- package/docs/interfaces/category.html +0 -279
- package/docs/interfaces/cellprops.html +0 -452
- package/docs/interfaces/combinatorrendererprops.html +0 -503
- package/docs/interfaces/combinatorsubschemarenderinfo.html +0 -181
- package/docs/interfaces/composablecondition.html +0 -193
- package/docs/interfaces/condition.html +0 -176
- package/docs/interfaces/controlelement.html +0 -280
- package/docs/interfaces/controlprops.html +0 -497
- package/docs/interfaces/controlstate.html +0 -184
- package/docs/interfaces/controlwithdetailprops.html +0 -501
- package/docs/interfaces/dispatchcellprops.html +0 -388
- package/docs/interfaces/dispatchcellstateprops.html +0 -408
- package/docs/interfaces/dispatchpropsofarraycontrol.html +0 -322
- package/docs/interfaces/dispatchpropsofcontrol.html +0 -204
- package/docs/interfaces/dispatchpropsofmultienumcontrol.html +0 -215
- package/docs/interfaces/enumcellprops.html +0 -467
- package/docs/interfaces/enumoption.html +0 -167
- package/docs/interfaces/formatted.html +0 -226
- package/docs/interfaces/grouplayout.html +0 -284
- package/docs/interfaces/horizontallayout.html +0 -234
- package/docs/interfaces/initaction.html +0 -209
- package/docs/interfaces/initactionoptions.html +0 -181
- package/docs/interfaces/internationalizable.html +0 -170
- package/docs/interfaces/jsonformscellrendererregistryentry.html +0 -167
- package/docs/interfaces/jsonformscore.html +0 -251
- package/docs/interfaces/jsonformsdefaultdataregistryentry.html +0 -167
- package/docs/interfaces/jsonformsextendedstate.html +0 -175
- package/docs/interfaces/jsonformsi18nstate.html +0 -181
- package/docs/interfaces/jsonformsprops.html +0 -321
- package/docs/interfaces/jsonformsrendererregistryentry.html +0 -167
- package/docs/interfaces/jsonformsstate.html +0 -170
- package/docs/interfaces/jsonformsstore.html +0 -376
- package/docs/interfaces/jsonformssubstates.html +0 -276
- package/docs/interfaces/jsonformsuischemaregistryentry.html +0 -167
- package/docs/interfaces/jsonschema4.html +0 -758
- package/docs/interfaces/jsonschema7.html +0 -884
- package/docs/interfaces/labelable.html +0 -184
- package/docs/interfaces/labeldescription.html +0 -184
- package/docs/interfaces/labeled.html +0 -182
- package/docs/interfaces/labelelement.html +0 -251
- package/docs/interfaces/labelprops.html +0 -339
- package/docs/interfaces/layout.html +0 -253
- package/docs/interfaces/layoutprops.html +0 -359
- package/docs/interfaces/leafcondition.html +0 -209
- package/docs/interfaces/orcondition.html +0 -181
- package/docs/interfaces/ownpropsofcell.html +0 -321
- package/docs/interfaces/ownpropsofcontrol.html +0 -305
- package/docs/interfaces/ownpropsofenum.html +0 -161
- package/docs/interfaces/ownpropsofenumcell.html +0 -335
- package/docs/interfaces/ownpropsofjsonformsrenderer.html +0 -296
- package/docs/interfaces/ownpropsoflabel.html +0 -286
- package/docs/interfaces/ownpropsoflayout.html +0 -305
- package/docs/interfaces/ownpropsofmasterlistitem.html +0 -289
- package/docs/interfaces/ownpropsofrenderer.html +0 -292
- package/docs/interfaces/referenceschemamap.html +0 -138
- package/docs/interfaces/registerdefaultdataaction.html +0 -181
- package/docs/interfaces/removecellrendereraction.html +0 -181
- package/docs/interfaces/removerendereraction.html +0 -181
- package/docs/interfaces/removeuischemaaction.html +0 -167
- package/docs/interfaces/rendererprops.html +0 -331
- package/docs/interfaces/rule.html +0 -185
- package/docs/interfaces/schemabasedcondition.html +0 -202
- package/docs/interfaces/scopable.html +0 -171
- package/docs/interfaces/scoped.html +0 -183
- package/docs/interfaces/setajvaction.html +0 -167
- package/docs/interfaces/setconfigaction.html +0 -167
- package/docs/interfaces/setlocaleaction.html +0 -167
- package/docs/interfaces/setschemaaction.html +0 -167
- package/docs/interfaces/settranslatoraction.html +0 -181
- package/docs/interfaces/setuischemaaction.html +0 -167
- package/docs/interfaces/setvalidationmodeaction.html +0 -167
- package/docs/interfaces/statepropsofarraycontrol.html +0 -474
- package/docs/interfaces/statepropsofarraylayout.html +0 -461
- package/docs/interfaces/statepropsofcell.html +0 -408
- package/docs/interfaces/statepropsofcombinator.html +0 -449
- package/docs/interfaces/statepropsofcontrol.html +0 -451
- package/docs/interfaces/statepropsofcontrolwithdetail.html +0 -463
- package/docs/interfaces/statepropsofenumcell.html +0 -422
- package/docs/interfaces/statepropsofjsonformsrenderer.html +0 -324
- package/docs/interfaces/statepropsoflabel.html +0 -343
- package/docs/interfaces/statepropsoflayout.html +0 -369
- package/docs/interfaces/statepropsofmasteritem.html +0 -309
- package/docs/interfaces/statepropsofrenderer.html +0 -331
- package/docs/interfaces/statepropsofscopedrenderer.html +0 -391
- package/docs/interfaces/store.html +0 -386
- package/docs/interfaces/testercontext.html +0 -184
- package/docs/interfaces/uischemaelement.html +0 -225
- package/docs/interfaces/unregisterdefaultdataaction.html +0 -167
- package/docs/interfaces/updateaction.html +0 -202
- package/docs/interfaces/updatecoreaction.html +0 -209
- package/docs/interfaces/updateerrorsaction.html +0 -167
- package/docs/interfaces/updatei18naction.html +0 -195
- package/docs/interfaces/verticallayout.html +0 -234
- package/docs/interfaces/withclassname.html +0 -153
- package/rollup.config.js +0 -44
- package/stats.html +0 -3279
- package/test/actions/actions.test.ts +0 -93
- package/test/generators/schema.test.ts +0 -224
- package/test/generators/uischema.test.ts +0 -576
- package/test/i18n/i18nUtil.test.ts +0 -88
- package/test/reducers/core.test.ts +0 -1682
- package/test/reducers/uischemas.test.ts +0 -173
- package/test/testers.test.ts +0 -948
- package/test/util/array.test.ts +0 -28
- package/test/util/cell.test.ts +0 -354
- package/test/util/derivetype.test.ts +0 -101
- package/test/util/label.test.ts +0 -364
- package/test/util/path.test.ts +0 -259
- package/test/util/renderer.test.ts +0 -1830
- package/test/util/resolvers.test.ts +0 -157
- package/test/util/runtime.test.ts +0 -779
- package/tsconfig.json +0 -13
package/test/util/array.test.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { moveDown, moveUp } from '../../src/util/';
|
|
2
|
-
import anyTest, { TestInterface } from 'ava';
|
|
3
|
-
|
|
4
|
-
const test = anyTest as TestInterface<{ array: number[] }>;
|
|
5
|
-
|
|
6
|
-
test.beforeEach(t => {
|
|
7
|
-
t.context.array = [1, 2, 3, 4, 5];
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test('Move up should move item up by one index', t => {
|
|
11
|
-
moveUp(t.context.array, 2);
|
|
12
|
-
t.deepEqual(t.context.array, [1, 3, 2, 4, 5]);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('Move up should not change array if item to move is the first item ', t => {
|
|
16
|
-
moveUp(t.context.array, 0);
|
|
17
|
-
t.deepEqual(t.context.array, [1, 2, 3, 4, 5]);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('Move down should move item down by one index', t => {
|
|
21
|
-
moveDown(t.context.array, 2);
|
|
22
|
-
t.deepEqual(t.context.array, [1, 2, 4, 3, 5]);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('Move down should not change array if item to move is the last item ', t => {
|
|
26
|
-
moveDown(t.context.array, 4);
|
|
27
|
-
t.deepEqual(t.context.array, [1, 2, 3, 4, 5]);
|
|
28
|
-
});
|
package/test/util/cell.test.ts
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import test from 'ava';
|
|
26
|
-
import * as _ from 'lodash';
|
|
27
|
-
import * as Redux from 'redux';
|
|
28
|
-
import {
|
|
29
|
-
clearAllIds,
|
|
30
|
-
defaultMapDispatchToControlProps,
|
|
31
|
-
defaultMapStateToEnumCellProps,
|
|
32
|
-
DispatchPropsOfCell,
|
|
33
|
-
mapStateToCellProps, mapStateToOneOfEnumCellProps, oneOfToEnumOptionMapper
|
|
34
|
-
} from '../../src/util';
|
|
35
|
-
import { UPDATE_DATA, UpdateAction } from '../../src/actions';
|
|
36
|
-
import configureStore from 'redux-mock-store';
|
|
37
|
-
import {
|
|
38
|
-
ControlElement,
|
|
39
|
-
JsonFormsState,
|
|
40
|
-
RuleEffect,
|
|
41
|
-
UISchemaElement
|
|
42
|
-
} from '../../src';
|
|
43
|
-
import { enumToEnumOptionMapper } from '../../src/util/renderer';
|
|
44
|
-
|
|
45
|
-
const middlewares: Redux.Middleware[] = [];
|
|
46
|
-
const mockStore = configureStore<JsonFormsState>(middlewares);
|
|
47
|
-
|
|
48
|
-
const hideRule = {
|
|
49
|
-
effect: RuleEffect.HIDE,
|
|
50
|
-
condition: {
|
|
51
|
-
type: 'LEAF',
|
|
52
|
-
scope: '#/properties/firstName',
|
|
53
|
-
expectedValue: 'Homer'
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const disableRule = {
|
|
58
|
-
effect: RuleEffect.DISABLE,
|
|
59
|
-
condition: {
|
|
60
|
-
type: 'LEAF',
|
|
61
|
-
scope: '#/properties/firstName',
|
|
62
|
-
expectedValue: 'Homer'
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const enableRule = {
|
|
67
|
-
effect: RuleEffect.ENABLE,
|
|
68
|
-
condition: {
|
|
69
|
-
type: 'LEAF',
|
|
70
|
-
scope: '#/properties/firstName',
|
|
71
|
-
expectedValue: 'Homer'
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const coreUISchema: ControlElement = {
|
|
76
|
-
type: 'Control',
|
|
77
|
-
scope: '#/properties/firstName'
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const createState = (uischema: UISchemaElement): JsonFormsState => ({
|
|
81
|
-
jsonforms: {
|
|
82
|
-
core: {
|
|
83
|
-
schema: {
|
|
84
|
-
type: 'object',
|
|
85
|
-
properties: {
|
|
86
|
-
firstName: { type: 'string' },
|
|
87
|
-
lastName: { type: 'string' },
|
|
88
|
-
nationality: {
|
|
89
|
-
type: 'string',
|
|
90
|
-
enum: ['DE', 'IT', 'JP', 'US', 'RU', 'Other']
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
data: {
|
|
95
|
-
firstName: 'Homer'
|
|
96
|
-
},
|
|
97
|
-
uischema,
|
|
98
|
-
errors: []
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('mapStateToCellProps - visible via ownProps ', t => {
|
|
104
|
-
const uischema: ControlElement = {
|
|
105
|
-
...coreUISchema,
|
|
106
|
-
rule: hideRule
|
|
107
|
-
};
|
|
108
|
-
const ownProps = {
|
|
109
|
-
visible: true,
|
|
110
|
-
uischema
|
|
111
|
-
};
|
|
112
|
-
const props = mapStateToCellProps(createState(uischema), ownProps);
|
|
113
|
-
t.true(props.visible);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test('mapStateToCellProps - hidden via ownProps ', t => {
|
|
117
|
-
const uischema = {
|
|
118
|
-
...coreUISchema,
|
|
119
|
-
rule: hideRule
|
|
120
|
-
};
|
|
121
|
-
const ownProps = {
|
|
122
|
-
visible: false,
|
|
123
|
-
uischema
|
|
124
|
-
};
|
|
125
|
-
const props = mapStateToCellProps(createState(uischema), ownProps);
|
|
126
|
-
t.false(props.visible);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test('mapStateToCellProps - hidden via state ', t => {
|
|
130
|
-
const uischema = {
|
|
131
|
-
...coreUISchema,
|
|
132
|
-
rule: hideRule
|
|
133
|
-
};
|
|
134
|
-
const ownProps = {
|
|
135
|
-
uischema
|
|
136
|
-
};
|
|
137
|
-
const props = mapStateToCellProps(createState(uischema), ownProps);
|
|
138
|
-
t.false(props.visible);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
test('mapStateToCellProps - visible via state ', t => {
|
|
142
|
-
const uischema = {
|
|
143
|
-
...coreUISchema,
|
|
144
|
-
rule: hideRule
|
|
145
|
-
};
|
|
146
|
-
const ownProps = {
|
|
147
|
-
uischema
|
|
148
|
-
};
|
|
149
|
-
const clonedState = _.cloneDeep(createState(uischema));
|
|
150
|
-
clonedState.jsonforms.core.data.firstName = 'Lisa';
|
|
151
|
-
const props = mapStateToCellProps(clonedState, ownProps);
|
|
152
|
-
t.true(props.visible);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test('mapStateToCellProps - enabled via ownProps ', t => {
|
|
156
|
-
const uischema = {
|
|
157
|
-
...coreUISchema,
|
|
158
|
-
rule: disableRule
|
|
159
|
-
};
|
|
160
|
-
const ownProps = {
|
|
161
|
-
enabled: true,
|
|
162
|
-
uischema
|
|
163
|
-
};
|
|
164
|
-
const props = mapStateToCellProps(createState(uischema), ownProps);
|
|
165
|
-
t.true(props.enabled);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test('mapStateToCellProps - disabled via ownProps ', t => {
|
|
169
|
-
const uischema = {
|
|
170
|
-
...coreUISchema,
|
|
171
|
-
rule: disableRule
|
|
172
|
-
};
|
|
173
|
-
const ownProps = {
|
|
174
|
-
enabled: false,
|
|
175
|
-
uischema
|
|
176
|
-
};
|
|
177
|
-
const props = mapStateToCellProps(createState(uischema), ownProps);
|
|
178
|
-
t.false(props.enabled);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
test('mapStateToCellProps - disabled via state ', t => {
|
|
182
|
-
const uischema = {
|
|
183
|
-
...coreUISchema,
|
|
184
|
-
rule: disableRule
|
|
185
|
-
};
|
|
186
|
-
const ownProps = {
|
|
187
|
-
uischema
|
|
188
|
-
};
|
|
189
|
-
const props = mapStateToCellProps(createState(uischema), ownProps);
|
|
190
|
-
t.false(props.enabled);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
test('mapStateToCellProps - enabled via state ', t => {
|
|
194
|
-
const uischema = {
|
|
195
|
-
...coreUISchema,
|
|
196
|
-
rule: disableRule
|
|
197
|
-
};
|
|
198
|
-
const ownProps = {
|
|
199
|
-
uischema
|
|
200
|
-
};
|
|
201
|
-
const clonedState = _.cloneDeep(createState(uischema));
|
|
202
|
-
clonedState.jsonforms.core.data.firstName = 'Lisa';
|
|
203
|
-
const props = mapStateToCellProps(clonedState, ownProps);
|
|
204
|
-
t.true(props.enabled);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
test('mapStateToCellProps - disabled via global readonly', t => {
|
|
208
|
-
const ownProps = {
|
|
209
|
-
uischema: coreUISchema
|
|
210
|
-
};
|
|
211
|
-
const state: JsonFormsState = createState(coreUISchema);
|
|
212
|
-
state.jsonforms.readonly = true;
|
|
213
|
-
|
|
214
|
-
const props = mapStateToCellProps(state, ownProps);
|
|
215
|
-
t.false(props.enabled);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
test('mapStateToCellProps - disabled via global readonly beats enabled via ownProps', t => {
|
|
219
|
-
const ownProps = {
|
|
220
|
-
uischema: coreUISchema,
|
|
221
|
-
enabled: true
|
|
222
|
-
};
|
|
223
|
-
const state: JsonFormsState = createState(coreUISchema);
|
|
224
|
-
state.jsonforms.readonly = true;
|
|
225
|
-
|
|
226
|
-
const props = mapStateToCellProps(state, ownProps);
|
|
227
|
-
t.false(props.enabled);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
test('mapStateToCellProps - disabled via global readonly beats enabled via rule', t => {
|
|
231
|
-
const uischema = {
|
|
232
|
-
...coreUISchema,
|
|
233
|
-
rule: enableRule
|
|
234
|
-
};
|
|
235
|
-
const ownProps = {
|
|
236
|
-
uischema
|
|
237
|
-
};
|
|
238
|
-
const state: JsonFormsState = createState(uischema);
|
|
239
|
-
state.jsonforms.readonly = true;
|
|
240
|
-
|
|
241
|
-
const props = mapStateToCellProps(state, ownProps);
|
|
242
|
-
t.false(props.enabled);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
test('mapStateToCellProps - path', t => {
|
|
246
|
-
const ownProps = {
|
|
247
|
-
uischema: coreUISchema,
|
|
248
|
-
path: 'firstName'
|
|
249
|
-
};
|
|
250
|
-
const props = mapStateToCellProps(createState(coreUISchema), ownProps);
|
|
251
|
-
t.is(props.path, 'firstName');
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
test('mapStateToCellProps - data', t => {
|
|
255
|
-
const ownProps = {
|
|
256
|
-
uischema: coreUISchema,
|
|
257
|
-
path: 'firstName'
|
|
258
|
-
};
|
|
259
|
-
const props = mapStateToCellProps(createState(coreUISchema), ownProps);
|
|
260
|
-
t.is(props.data, 'Homer');
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test('mapStateToCellProps - id', t => {
|
|
264
|
-
clearAllIds();
|
|
265
|
-
const ownProps = {
|
|
266
|
-
uischema: coreUISchema,
|
|
267
|
-
id: '#/properties/firstName'
|
|
268
|
-
};
|
|
269
|
-
const props = mapStateToCellProps(createState(coreUISchema), ownProps);
|
|
270
|
-
t.is(props.id, '#/properties/firstName');
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
test('mapStateToEnumCellProps - set default options for dropdown list', t => {
|
|
274
|
-
const uischema: ControlElement = {
|
|
275
|
-
type: 'Control',
|
|
276
|
-
scope: '#/properties/nationality'
|
|
277
|
-
};
|
|
278
|
-
const ownProps = {
|
|
279
|
-
schema: {
|
|
280
|
-
enum: ['DE', 'IT', 'JP', 'US', 'RU', 'Other']
|
|
281
|
-
},
|
|
282
|
-
uischema,
|
|
283
|
-
path: 'nationality'
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
const props = defaultMapStateToEnumCellProps(createState(uischema), ownProps);
|
|
287
|
-
t.deepEqual(
|
|
288
|
-
props.options,
|
|
289
|
-
['DE', 'IT', 'JP', 'US', 'RU', 'Other'].map(e => enumToEnumOptionMapper(e))
|
|
290
|
-
);
|
|
291
|
-
t.is(props.data, undefined);
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
test('mapStateToOneOfEnumCellProps - set one of options for dropdown list', t => {
|
|
296
|
-
const uischema: ControlElement = {
|
|
297
|
-
type: 'Control',
|
|
298
|
-
scope: '#/properties/country'
|
|
299
|
-
};
|
|
300
|
-
const ownProps = {
|
|
301
|
-
schema: {
|
|
302
|
-
oneOf: [
|
|
303
|
-
{
|
|
304
|
-
const: 'AU',
|
|
305
|
-
title: 'Australia'
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
const: 'NZ',
|
|
309
|
-
title: 'New Zealand'
|
|
310
|
-
}
|
|
311
|
-
]
|
|
312
|
-
},
|
|
313
|
-
uischema,
|
|
314
|
-
path: 'country'
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
const props = mapStateToOneOfEnumCellProps(createState(uischema), ownProps);
|
|
318
|
-
t.deepEqual(props.options, [{title: 'Australia' , const: 'AU', }, { title: 'New Zealand', const: 'NZ' }].map(schema => oneOfToEnumOptionMapper(schema)));
|
|
319
|
-
t.is(props.data, undefined);
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
test('defaultMapDispatchToControlProps, initialized with custom handleChange', t => {
|
|
323
|
-
let didChange = false;
|
|
324
|
-
const uiSchema = {
|
|
325
|
-
type: 'Control',
|
|
326
|
-
scope: '#/properties/nationality'
|
|
327
|
-
};
|
|
328
|
-
const ownProps = {
|
|
329
|
-
handleChange: () => {
|
|
330
|
-
didChange = true;
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
const store = mockStore(createState(uiSchema));
|
|
334
|
-
const props: DispatchPropsOfCell = defaultMapDispatchToControlProps(
|
|
335
|
-
store.dispatch,
|
|
336
|
-
ownProps
|
|
337
|
-
);
|
|
338
|
-
props.handleChange(undefined, undefined);
|
|
339
|
-
t.true(didChange);
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
test('defaultMapDispatchToControlProps, with default handleChange', t => {
|
|
343
|
-
const uiSchema = {
|
|
344
|
-
type: 'Control',
|
|
345
|
-
scope: '#/properties/nationality'
|
|
346
|
-
};
|
|
347
|
-
const store = mockStore(createState(uiSchema));
|
|
348
|
-
const props = defaultMapDispatchToControlProps(store.dispatch, {});
|
|
349
|
-
props.handleChange('nationality', 'DE');
|
|
350
|
-
const updateAction = _.head<any>(store.getActions()) as UpdateAction;
|
|
351
|
-
t.is(updateAction.type, UPDATE_DATA);
|
|
352
|
-
t.is(updateAction.path, 'nationality');
|
|
353
|
-
t.is(updateAction.updater(), 'DE');
|
|
354
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import test from 'ava';
|
|
26
|
-
|
|
27
|
-
import { JsonSchema } from '../../src/models/jsonSchema';
|
|
28
|
-
import { deriveTypes } from '../../src/util/index';
|
|
29
|
-
|
|
30
|
-
test('derive type with type', t => {
|
|
31
|
-
const schema: JsonSchema = {
|
|
32
|
-
type: 'string'
|
|
33
|
-
};
|
|
34
|
-
t.is(deriveTypes(schema).length, 1);
|
|
35
|
-
t.is(deriveTypes(schema)[0], 'string');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('derive type w/o type - properties object', t => {
|
|
39
|
-
const schema: JsonSchema = {
|
|
40
|
-
properties: {
|
|
41
|
-
foo: { type: 'string' }
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
t.is(deriveTypes(schema).length, 1);
|
|
45
|
-
t.is(deriveTypes(schema)[0], 'object');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('derive type w/o type - additionalProperties object', t => {
|
|
49
|
-
const schema: JsonSchema = {
|
|
50
|
-
additionalProperties: {
|
|
51
|
-
type: 'string'
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
t.is(deriveTypes(schema).length, 1);
|
|
55
|
-
t.is(deriveTypes(schema)[0], 'object');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('derive type w/o type - items array', t => {
|
|
59
|
-
const schema: JsonSchema = {
|
|
60
|
-
items: {
|
|
61
|
-
type: 'string'
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
t.is(deriveTypes(schema).length, 1);
|
|
65
|
-
t.is(deriveTypes(schema)[0], 'array');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('derive type with type - union', t => {
|
|
69
|
-
const schema: JsonSchema = {
|
|
70
|
-
type: ['string', 'number']
|
|
71
|
-
};
|
|
72
|
-
t.is(deriveTypes(schema).length, 2);
|
|
73
|
-
t.is(deriveTypes(schema), schema.type);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('derive type with type - allOf first has type', t => {
|
|
77
|
-
const schema: JsonSchema = {
|
|
78
|
-
allOf: [{ type: 'string' }, { enum: ['foo', 'bar'] }]
|
|
79
|
-
};
|
|
80
|
-
t.is(deriveTypes(schema).length, 1);
|
|
81
|
-
t.is(deriveTypes(schema)[0], 'string');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('derive type with type - allOf other has type', t => {
|
|
85
|
-
const schema: JsonSchema = {
|
|
86
|
-
allOf: [{ enum: ['foo', 'bar'] }, { type: 'string' }]
|
|
87
|
-
};
|
|
88
|
-
t.is(deriveTypes(schema).length, 1);
|
|
89
|
-
t.is(deriveTypes(schema)[0], 'string');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test('derive type w/o type - allOf other has type', t => {
|
|
93
|
-
const schema: JsonSchema = {
|
|
94
|
-
allOf: [
|
|
95
|
-
{ properties: { foo: { type: 'string' } } },
|
|
96
|
-
{ properties: { bar: { type: 'string' } } }
|
|
97
|
-
]
|
|
98
|
-
};
|
|
99
|
-
t.is(deriveTypes(schema).length, 1);
|
|
100
|
-
t.is(deriveTypes(schema)[0], 'object');
|
|
101
|
-
});
|