@jsonforms/core 3.0.0-beta.3 → 3.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +11 -0
  2. package/docs/assets/js/search.json +1 -1
  3. package/docs/enums/ruleeffect.html +4 -4
  4. package/docs/globals.html +371 -115
  5. package/docs/index.html +59 -4
  6. package/docs/interfaces/andcondition.html +2 -2
  7. package/docs/interfaces/arraycontrolprops.html +21 -21
  8. package/docs/interfaces/arraylayoutprops.html +21 -21
  9. package/docs/interfaces/categorization.html +24 -16
  10. package/docs/interfaces/category.html +24 -16
  11. package/docs/interfaces/cellprops.html +12 -12
  12. package/docs/interfaces/combinatorrendererprops.html +18 -18
  13. package/docs/interfaces/composablecondition.html +2 -2
  14. package/docs/interfaces/condition.html +1 -1
  15. package/docs/interfaces/controlelement.html +38 -15
  16. package/docs/interfaces/controlprops.html +16 -16
  17. package/docs/interfaces/controlstate.html +2 -2
  18. package/docs/interfaces/controlwithdetailprops.html +17 -17
  19. package/docs/interfaces/dispatchcellprops.html +10 -10
  20. package/docs/interfaces/dispatchcellstateprops.html +10 -10
  21. package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
  22. package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
  23. package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
  24. package/docs/interfaces/enumcellprops.html +13 -13
  25. package/docs/interfaces/enumoption.html +2 -2
  26. package/docs/interfaces/grouplayout.html +24 -12
  27. package/docs/interfaces/horizontallayout.html +4 -4
  28. package/docs/interfaces/internationalizable.html +161 -0
  29. package/docs/interfaces/jsonformsprops.html +24 -9
  30. package/docs/interfaces/labelable.html +184 -0
  31. package/docs/interfaces/labeldescription.html +2 -2
  32. package/docs/interfaces/labeled.html +182 -0
  33. package/docs/interfaces/labelelement.html +22 -4
  34. package/docs/interfaces/labelprops.html +339 -0
  35. package/docs/interfaces/layout.html +4 -4
  36. package/docs/interfaces/layoutprops.html +25 -10
  37. package/docs/interfaces/leafcondition.html +9 -8
  38. package/docs/interfaces/orcondition.html +2 -2
  39. package/docs/interfaces/ownpropsofcell.html +9 -9
  40. package/docs/interfaces/ownpropsofcontrol.html +9 -9
  41. package/docs/interfaces/ownpropsofenum.html +1 -1
  42. package/docs/interfaces/ownpropsofenumcell.html +10 -10
  43. package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
  44. package/docs/interfaces/ownpropsoflabel.html +286 -0
  45. package/docs/interfaces/ownpropsoflayout.html +9 -9
  46. package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
  47. package/docs/interfaces/ownpropsofrenderer.html +11 -8
  48. package/docs/interfaces/rendererprops.html +9 -9
  49. package/docs/interfaces/rule.html +2 -2
  50. package/docs/interfaces/schemabasedcondition.html +9 -8
  51. package/docs/interfaces/scopable.html +3 -9
  52. package/docs/interfaces/scoped.html +183 -0
  53. package/docs/interfaces/statepropsofarraycontrol.html +17 -17
  54. package/docs/interfaces/statepropsofarraylayout.html +17 -17
  55. package/docs/interfaces/statepropsofcell.html +11 -11
  56. package/docs/interfaces/statepropsofcombinator.html +17 -17
  57. package/docs/interfaces/statepropsofcontrol.html +15 -15
  58. package/docs/interfaces/statepropsofcontrolwithdetail.html +16 -16
  59. package/docs/interfaces/statepropsofenumcell.html +12 -12
  60. package/docs/interfaces/statepropsofjsonformsrenderer.html +23 -9
  61. package/docs/interfaces/statepropsoflabel.html +343 -0
  62. package/docs/interfaces/statepropsoflayout.html +24 -10
  63. package/docs/interfaces/statepropsofmasteritem.html +7 -7
  64. package/docs/interfaces/statepropsofrenderer.html +12 -9
  65. package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
  66. package/docs/interfaces/testercontext.html +184 -0
  67. package/docs/interfaces/uischemaelement.html +3 -3
  68. package/docs/interfaces/verticallayout.html +4 -4
  69. package/docs/interfaces/withclassname.html +1 -1
  70. package/lib/i18n/i18nUtil.d.ts +9 -4
  71. package/lib/jsonforms-core.cjs.js +103 -50
  72. package/lib/jsonforms-core.cjs.js.map +1 -1
  73. package/lib/jsonforms-core.esm.js +85 -50
  74. package/lib/jsonforms-core.esm.js.map +1 -1
  75. package/lib/models/uischema.d.ts +41 -24
  76. package/lib/reducers/i18n.d.ts +1 -1
  77. package/lib/testers/testers.d.ts +15 -6
  78. package/lib/util/renderer.d.ts +18 -1
  79. package/lib/util/runtime.d.ts +1 -2
  80. package/lib/util/util.d.ts +6 -6
  81. package/package.json +2 -2
  82. package/src/i18n/i18nUtil.ts +28 -8
  83. package/src/models/uischema.ts +60 -24
  84. package/src/reducers/i18n.ts +1 -1
  85. package/src/testers/testers.ts +43 -36
  86. package/src/util/path.ts +9 -5
  87. package/src/util/renderer.ts +52 -25
  88. package/src/util/runtime.ts +1 -1
  89. package/src/util/util.ts +8 -8
  90. package/stats.html +1 -1
  91. package/test/i18n/i18nUtil.test.ts +41 -1
  92. package/test/testers.test.ts +40 -23
  93. package/test/util/renderer.test.ts +106 -8
@@ -46,7 +46,8 @@ import {
46
46
  scopeEndIs,
47
47
  scopeEndsWith,
48
48
  uiTypeIs,
49
- isOneOfEnumControl
49
+ isOneOfEnumControl,
50
+ TesterContext
50
51
  } from '../src/testers';
51
52
  import {
52
53
  ControlElement,
@@ -57,6 +58,9 @@ import {
57
58
 
58
59
  const test = anyTest as TestInterface<{ uischema: ControlElement }>;
59
60
 
61
+ const createTesterContext =
62
+ (rootSchema: JsonSchema, config?: any): TesterContext => ({ rootSchema, config });
63
+
60
64
  test.beforeEach(t => {
61
65
  t.context.uischema = {
62
66
  type: 'Control',
@@ -75,8 +79,9 @@ test('schemaTypeIs should check type sub-schema of control', t => {
75
79
  type: 'Control',
76
80
  scope: '#/properties/foo'
77
81
  };
78
- t.true(schemaTypeIs('string')(uischema, schema, schema));
79
- t.false(schemaTypeIs('integer')(uischema, schema, schema));
82
+ const testerContext = createTesterContext(schema);
83
+ t.true(schemaTypeIs('string')(uischema, schema, testerContext));
84
+ t.false(schemaTypeIs('integer')(uischema, schema, testerContext));
80
85
  });
81
86
 
82
87
  test('schemaTypeIs should return false for non-control UI schema elements', t => {
@@ -90,7 +95,8 @@ test('schemaTypeIs should return false for non-control UI schema elements', t =>
90
95
  type: 'Label',
91
96
  text: 'some text'
92
97
  };
93
- t.false(schemaTypeIs('integer')(label, schema, schema));
98
+ const testerContext = createTesterContext(schema);
99
+ t.false(schemaTypeIs('integer')(label, schema, testerContext));
94
100
  });
95
101
 
96
102
  test('schemaTypeIs should return false for control pointing to invalid sub-schema', t => {
@@ -104,7 +110,8 @@ test('schemaTypeIs should return false for control pointing to invalid sub-schem
104
110
  foo: { type: 'string' }
105
111
  }
106
112
  };
107
- t.false(schemaTypeIs('string')(uischema, schema, schema));
113
+ const testerContext = createTesterContext(schema);
114
+ t.false(schemaTypeIs('string')(uischema, schema, testerContext));
108
115
  });
109
116
 
110
117
  test('schemaTypeIs should return true for array type', t => {
@@ -118,8 +125,9 @@ test('schemaTypeIs should return true for array type', t => {
118
125
  type: 'Control',
119
126
  scope: '#/properties/foo'
120
127
  };
121
- t.true(schemaTypeIs('string')(uischema, schema, schema));
122
- t.true(schemaTypeIs('integer')(uischema, schema, schema));
128
+ const testerContext = createTesterContext(schema);
129
+ t.true(schemaTypeIs('string')(uischema, schema, testerContext));
130
+ t.true(schemaTypeIs('integer')(uischema, schema, testerContext));
123
131
  });
124
132
 
125
133
  test('formatIs should check the format of a resolved sub-schema', t => {
@@ -136,7 +144,8 @@ test('formatIs should check the format of a resolved sub-schema', t => {
136
144
  }
137
145
  }
138
146
  };
139
- t.true(formatIs('date-time')(uischema, schema, schema));
147
+ const testerContext = createTesterContext(schema);
148
+ t.true(formatIs('date-time')(uischema, schema, testerContext));
140
149
  });
141
150
 
142
151
  test('uiTypeIs', t => {
@@ -183,8 +192,9 @@ test('schemaMatches should check type sub-schema of control via predicate', t =>
183
192
  type: 'Control',
184
193
  scope: '#/properties/foo'
185
194
  };
195
+ const testerContext = createTesterContext(schema);
186
196
  t.true(
187
- schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema, schema)
197
+ schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema, testerContext)
188
198
  );
189
199
  });
190
200
 
@@ -198,8 +208,9 @@ test('schemaMatches should check type sub-schema of control via predicate also w
198
208
  type: 'Control',
199
209
  scope: '#/properties/foo'
200
210
  };
211
+ const testerContext = createTesterContext(schema);
201
212
  t.true(
202
- schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema, schema)
213
+ schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema, testerContext)
203
214
  );
204
215
  });
205
216
 
@@ -214,7 +225,8 @@ test('schemaMatches should return false for non-control UI schema elements', t =
214
225
  type: 'Label',
215
226
  text: 'some text'
216
227
  };
217
- t.false(schemaMatches(() => false)(label, schema, schema));
228
+ const testerContext = createTesterContext(schema);
229
+ t.false(schemaMatches(() => false)(label, schema, testerContext));
218
230
  });
219
231
 
220
232
  test('schemaMatches should return false for control pointing to invalid subschema', t => {
@@ -228,7 +240,8 @@ test('schemaMatches should return false for control pointing to invalid subschem
228
240
  type: 'Control',
229
241
  scope: '#/properties/bar'
230
242
  };
231
- t.false(schemaMatches(() => false)(uischema, schema, schema));
243
+ const testerContext = createTesterContext(schema);
244
+ t.false(schemaMatches(() => false)(uischema, schema, testerContext));
232
245
  });
233
246
 
234
247
  test('scopeEndsWith checks whether the ref of a control ends with a certain string', t => {
@@ -274,7 +287,8 @@ test('and should allow to compose multiple testers', t => {
274
287
  type: 'Control',
275
288
  scope: '#/properties/foo'
276
289
  };
277
- t.true(and(schemaTypeIs('string'), scopeEndIs('foo'))(uischema, schema, schema));
290
+ const testerContext = createTesterContext(schema);
291
+ t.true(and(schemaTypeIs('string'), scopeEndIs('foo'))(uischema, schema, testerContext));
278
292
  });
279
293
 
280
294
  test('or should allow to compose multiple testers', t => {
@@ -288,8 +302,9 @@ test('or should allow to compose multiple testers', t => {
288
302
  type: 'Control',
289
303
  scope: '#/properties/foo'
290
304
  };
305
+ const testerContext = createTesterContext(schema);
291
306
  t.true(
292
- or(schemaTypeIs('integer'), optionIs('slider', true))(uischema, schema, schema)
307
+ or(schemaTypeIs('integer'), optionIs('slider', true))(uischema, schema, testerContext)
293
308
  );
294
309
  });
295
310
 
@@ -308,7 +323,7 @@ test('tester isPrimitiveArrayControl', t => {
308
323
  }
309
324
  };
310
325
  t.true(
311
- isPrimitiveArrayControl(control, schema, schema),
326
+ isPrimitiveArrayControl(control, schema, createTesterContext(schema)),
312
327
  `Primitive array tester was not triggered for 'integer' schema type`
313
328
  );
314
329
  const schemaWithRefs = {
@@ -322,7 +337,7 @@ test('tester isPrimitiveArrayControl', t => {
322
337
  }
323
338
  };
324
339
  t.true(
325
- isPrimitiveArrayControl(control, schemaWithRefs, schemaWithRefs),
340
+ isPrimitiveArrayControl(control, schemaWithRefs, createTesterContext(schemaWithRefs)),
326
341
  `Primitive array tester was not triggered for 'integer' schema type with refs`
327
342
  );
328
343
  const objectSchema = {
@@ -335,7 +350,7 @@ test('tester isPrimitiveArrayControl', t => {
335
350
  }
336
351
  };
337
352
  t.false(
338
- isPrimitiveArrayControl(control, objectSchema, objectSchema),
353
+ isPrimitiveArrayControl(control, objectSchema, createTesterContext(objectSchema)),
339
354
  `Primitive array tester was not triggered for 'object' schema type`
340
355
  );
341
356
  });
@@ -401,7 +416,7 @@ test('tester isObjectArrayControl', t => {
401
416
  }
402
417
  }
403
418
  };
404
- t.true(isObjectArrayControl(control, schema, schema));
419
+ t.true(isObjectArrayControl(control, schema, createTesterContext(schema)));
405
420
  const schema_noType: JsonSchema = {
406
421
  type: 'object',
407
422
  properties: {
@@ -416,7 +431,7 @@ test('tester isObjectArrayControl', t => {
416
431
  }
417
432
  }
418
433
  };
419
- t.true(isObjectArrayControl(control, schema_noType, schema_noType));
434
+ t.true(isObjectArrayControl(control, schema_noType, createTesterContext(schema_noType)));
420
435
  const schema_innerAllOf: JsonSchema = {
421
436
  type: 'object',
422
437
  properties: {
@@ -439,7 +454,7 @@ test('tester isObjectArrayControl', t => {
439
454
  }
440
455
  }
441
456
  };
442
- t.true(isObjectArrayControl(control, schema_innerAllOf, schema_innerAllOf));
457
+ t.true(isObjectArrayControl(control, schema_innerAllOf, createTesterContext(schema_innerAllOf)));
443
458
 
444
459
  const schemaWithRefs = {
445
460
  definitions: {
@@ -461,7 +476,8 @@ test('tester isObjectArrayControl', t => {
461
476
  }
462
477
  }
463
478
  }
464
- t.true(isObjectArrayControl(control, schemaWithRefs, schemaWithRefs));
479
+ const testerContext = createTesterContext(schemaWithRefs);
480
+ t.true(isObjectArrayControl(control, schemaWithRefs, testerContext));
465
481
  });
466
482
 
467
483
  test('isBooleanControl', t => {
@@ -801,7 +817,7 @@ test('tester isObjectArrayWithNesting', t => {
801
817
  t.true(isObjectArrayWithNesting(uischema, nestedSchema, undefined));
802
818
  t.true(isObjectArrayWithNesting(uischema, nestedSchema2, undefined));
803
819
  t.true(isObjectArrayWithNesting(uischema, nestedSchema3, undefined));
804
- t.true(isObjectArrayWithNesting(uischema, nestedSchemaWithRef, nestedSchemaWithRef));
820
+ t.true(isObjectArrayWithNesting(uischema, nestedSchemaWithRef, createTesterContext(nestedSchemaWithRef)));
805
821
 
806
822
  t.false(isObjectArrayWithNesting(uischemaOptions.default, schema, undefined));
807
823
  t.true(isObjectArrayWithNesting(uischemaOptions.generate, schema, undefined));
@@ -872,5 +888,6 @@ test('tester isOneOfEnumControl', t => {
872
888
  }
873
889
  }
874
890
  }
875
- t.true(isOneOfEnumControl(control, schemaWithRefs, schemaWithRefs));
891
+ const testerContext = createTesterContext(schemaWithRefs);
892
+ t.true(isOneOfEnumControl(control, schemaWithRefs, testerContext));
876
893
  });
@@ -32,10 +32,9 @@ import { JsonFormsState } from '../../src/store';
32
32
  import { coreReducer, JsonFormsCore } from '../../src/reducers/core';
33
33
  import { Dispatch } from '../../src/util/type';
34
34
  import { CoreActions, init, setValidationMode, update, UpdateAction, UPDATE_DATA } from '../../src/actions/actions';
35
- import { ControlElement, RuleEffect, UISchemaElement } from '../../src/models/uischema';
36
- import { computeLabel, createDefaultValue, mapDispatchToArrayControlProps, mapDispatchToControlProps, mapDispatchToMultiEnumProps, mapStateToAnyOfProps, mapStateToArrayLayoutProps, mapStateToControlProps, mapStateToEnumControlProps, mapStateToJsonFormsRendererProps, mapStateToLayoutProps, mapStateToMultiEnumControlProps, mapStateToOneOfEnumControlProps, mapStateToOneOfProps, OwnPropsOfControl } from '../../src/util/renderer';
35
+ import { ControlElement, LabelElement, RuleEffect, UISchemaElement } from '../../src/models/uischema';
36
+ import { computeLabel, createDefaultValue, mapDispatchToArrayControlProps, mapDispatchToControlProps, mapDispatchToMultiEnumProps, mapStateToAnyOfProps, mapStateToArrayLayoutProps, mapStateToControlProps, mapStateToEnumControlProps, mapStateToJsonFormsRendererProps, mapStateToLabelProps, mapStateToLayoutProps, mapStateToMultiEnumControlProps, mapStateToOneOfEnumControlProps, mapStateToOneOfProps, OwnPropsOfControl } from '../../src/util/renderer';
37
37
  import { clearAllIds } from '../../src/util/ids';
38
- import { generateDefaultUISchema } from '../../src/generators/uischema';
39
38
  import { JsonSchema } from '../../src/models/jsonSchema';
40
39
  import { rankWith } from '../../src/testers/testers';
41
40
  import { createAjv } from '../../src/util/validator';
@@ -495,7 +494,7 @@ test('createDefaultValue', t => {
495
494
  t.deepEqual(createDefaultValue({ type: 'something' }), {});
496
495
  });
497
496
 
498
- test(`mapStateToDispatchRendererProps should generate UI schema given ownProps schema`, t => {
497
+ test(`mapStateToJsonFormsRendererProps should use registered UI schema given ownProps schema`, t => {
499
498
  const store = mockStore(createState(coreUISchema));
500
499
  const schema = {
501
500
  type: 'object',
@@ -507,16 +506,16 @@ test(`mapStateToDispatchRendererProps should generate UI schema given ownProps s
507
506
  };
508
507
 
509
508
  const props = mapStateToJsonFormsRendererProps(store.getState(), { schema });
510
- t.deepEqual(props.uischema, generateDefaultUISchema(schema));
509
+ t.deepEqual(props.uischema, coreUISchema);
511
510
  });
512
511
 
513
- test(`mapStateToDispatchRendererProps should use registered UI schema given no ownProps`, t => {
512
+ test(`mapStateToJsonFormsRendererProps should use registered UI schema given no ownProps`, t => {
514
513
  const store = mockStore(createState(coreUISchema));
515
514
  const props = mapStateToJsonFormsRendererProps(store.getState(), {});
516
515
  t.deepEqual(props.uischema, coreUISchema);
517
516
  });
518
517
 
519
- test(`mapStateToDispatchRendererProps should use UI schema if given via ownProps`, t => {
518
+ test(`mapStateToJsonFormsRendererProps should use UI schema if given via ownProps`, t => {
520
519
  const store = mockStore(createState(coreUISchema));
521
520
  const schema = {
522
521
  type: 'object',
@@ -1344,7 +1343,7 @@ test('mapStateToControlProps - i18n - translation via UI Schema i18n key', t =>
1344
1343
  };
1345
1344
  const state: JsonFormsState = createState(coreUISchema);
1346
1345
  state.jsonforms.i18n = defaultJsonFormsI18nState;
1347
- ownProps.uischema = {...ownProps.uischema, options: {i18n: 'my-key'}};
1346
+ ownProps.uischema = {...ownProps.uischema, i18n: 'my-key'};
1348
1347
  state.jsonforms.i18n.translate = (key: string, defaultMessage: string | undefined) => {
1349
1348
  switch(key){
1350
1349
  case 'my-key.label': return 'my label';
@@ -1730,3 +1729,102 @@ test('mapStateToOneOfEnumControlProps - i18n - i18n key translation', t => {
1730
1729
  const props = mapStateToOneOfEnumControlProps(state, ownProps);
1731
1730
  t.is(props.options[0].label, 'my message');
1732
1731
  });
1732
+
1733
+
1734
+ test('mapStateToLabelProps - i18n - should not crash without i18n', t => {
1735
+ const labelUISchema : LabelElement = {
1736
+ type: 'Label',
1737
+ text: 'foo',
1738
+ i18n: 'bar'
1739
+ }
1740
+ const ownProps = {
1741
+ uischema: labelUISchema
1742
+ };
1743
+ const state: JsonFormsState = createState(labelUISchema);
1744
+ state.jsonforms.i18n = undefined;
1745
+
1746
+ const props = mapStateToLabelProps(state, ownProps);
1747
+ t.is(props.text, 'foo');
1748
+ });
1749
+
1750
+ test('mapStateToLabelProps - i18n - default translation has no effect', t => {
1751
+ const labelUISchema : LabelElement = {
1752
+ type: 'Label',
1753
+ text: 'foo',
1754
+ i18n: 'bar'
1755
+ }
1756
+ const ownProps = {
1757
+ uischema: labelUISchema
1758
+ };
1759
+ const state: JsonFormsState = createState(labelUISchema);
1760
+ state.jsonforms.i18n = defaultJsonFormsI18nState;
1761
+
1762
+ const props = mapStateToLabelProps(state, ownProps);
1763
+ t.is(props.text, 'foo');
1764
+ });
1765
+
1766
+ test('mapStateToLabelProps - i18n - default key translation', t => {
1767
+ const labelUISchema : LabelElement = {
1768
+ type: 'Label',
1769
+ text: 'foo'
1770
+ }
1771
+ const ownProps = {
1772
+ uischema: labelUISchema
1773
+ };
1774
+ const state: JsonFormsState = createState(labelUISchema);
1775
+ state.jsonforms.i18n = defaultJsonFormsI18nState;
1776
+ state.jsonforms.i18n.translate = (key: string, defaultMessage: string | undefined) => {
1777
+ switch(key){
1778
+ case 'foo': return 'my message';
1779
+ default: return defaultMessage;
1780
+ }
1781
+ }
1782
+
1783
+ const props = mapStateToLabelProps(state, ownProps);
1784
+ t.is(props.text, 'my message');
1785
+ });
1786
+
1787
+
1788
+ test('mapStateToLabelProps - i18n - default message translation', t => {
1789
+ const labelUISchema : LabelElement = {
1790
+ type: 'Label',
1791
+ text: 'foo',
1792
+ i18n: 'bar'
1793
+ }
1794
+ const ownProps = {
1795
+ uischema: labelUISchema
1796
+ };
1797
+ const state: JsonFormsState = createState(labelUISchema);
1798
+ state.jsonforms.i18n = defaultJsonFormsI18nState;
1799
+ state.jsonforms.i18n.translate = (_key: string, defaultMessage: string | undefined) => {
1800
+ switch(defaultMessage){
1801
+ case 'foo': return 'my message';
1802
+ default: return defaultMessage;
1803
+ }
1804
+ }
1805
+
1806
+ const props = mapStateToLabelProps(state, ownProps);
1807
+ t.is(props.text, 'my message');
1808
+ });
1809
+
1810
+ test('mapStateToLabelProps - i18n - i18n key translation', t => {
1811
+ const labelUISchema : LabelElement = {
1812
+ type: 'Label',
1813
+ text: 'foo',
1814
+ i18n: 'bar'
1815
+ }
1816
+ const ownProps = {
1817
+ uischema: labelUISchema
1818
+ };
1819
+ const state: JsonFormsState = createState(labelUISchema);
1820
+ state.jsonforms.i18n = defaultJsonFormsI18nState;
1821
+ state.jsonforms.i18n.translate = (key: string, defaultMessage: string | undefined): string | undefined => {
1822
+ switch(key){
1823
+ case 'bar.text': return 'my message';
1824
+ default: return defaultMessage;
1825
+ }
1826
+ }
1827
+
1828
+ const props = mapStateToLabelProps(state, ownProps);
1829
+ t.is(props.text, 'my message');
1830
+ });