@jsonforms/material-renderers 3.0.0-beta.1 → 3.0.0-beta.4

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 (52) hide show
  1. package/README.md +71 -13
  2. package/docs/globals.html +55 -85
  3. package/docs/index.html +70 -13
  4. package/docs/interfaces/emptytableprops.html +1 -1
  5. package/docs/interfaces/nonemptycellcomponentprops.html +9 -9
  6. package/docs/interfaces/nonemptycellprops.html +9 -9
  7. package/docs/interfaces/ownoneofprops.html +1 -1
  8. package/docs/interfaces/ownpropsofnonemptycell.html +6 -6
  9. package/docs/interfaces/tableheadercellprops.html +1 -1
  10. package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
  11. package/lib/jsonforms-react-material.cjs.js +20 -28
  12. package/lib/jsonforms-react-material.cjs.js.map +1 -1
  13. package/lib/jsonforms-react-material.esm.js +19 -27
  14. package/lib/jsonforms-react-material.esm.js.map +1 -1
  15. package/lib/layouts/MaterialArrayLayoutRenderer.d.ts +1 -1
  16. package/package.json +8 -6
  17. package/src/additional/MaterialListWithDetailRenderer.tsx +5 -3
  18. package/src/complex/MaterialAllOfRenderer.tsx +3 -5
  19. package/src/complex/MaterialAnyOfRenderer.tsx +3 -5
  20. package/src/complex/MaterialEnumArrayRenderer.tsx +1 -2
  21. package/src/complex/MaterialObjectRenderer.tsx +3 -8
  22. package/src/complex/MaterialOneOfRenderer.tsx +3 -5
  23. package/src/complex/MaterialTableControl.tsx +6 -6
  24. package/src/layouts/ExpandPanelRenderer.tsx +2 -1
  25. package/src/layouts/MaterialArrayLayoutRenderer.tsx +3 -25
  26. package/stats.html +1 -1
  27. package/test/renderers/MaterialAnyOfStringOrEnumControl.test.tsx +7 -7
  28. package/test/renderers/MaterialArrayLayout.test.tsx +66 -8
  29. package/test/renderers/MaterialBooleanCell.test.tsx +10 -7
  30. package/test/renderers/MaterialBooleanToggleCell.test.tsx +14 -9
  31. package/test/renderers/MaterialBooleanToggleControl.test.tsx +14 -9
  32. package/test/renderers/MaterialCategorizationLayout.test.tsx +12 -12
  33. package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +12 -12
  34. package/test/renderers/MaterialDateCell.test.tsx +10 -7
  35. package/test/renderers/MaterialDateControl.test.tsx +12 -8
  36. package/test/renderers/MaterialDateTimeControl.test.tsx +12 -8
  37. package/test/renderers/MaterialEnumArrayRenderer.test.tsx +9 -7
  38. package/test/renderers/MaterialEnumCell.test.tsx +2 -1
  39. package/test/renderers/MaterialEnumControl.test.tsx +75 -0
  40. package/test/renderers/MaterialIntegerCell.test.tsx +10 -7
  41. package/test/renderers/MaterialLabelRenderer.test.tsx +4 -4
  42. package/test/renderers/MaterialListWithDetailRenderer.test.tsx +5 -5
  43. package/test/renderers/MaterialNumberCell.test.tsx +10 -7
  44. package/test/renderers/MaterialObjectControl.test.tsx +10 -7
  45. package/test/renderers/MaterialOneOfEnumCell.test.tsx +2 -1
  46. package/test/renderers/MaterialOneOfRadioGroupControl.test.tsx +3 -2
  47. package/test/renderers/MaterialOneOfRenderer.test.tsx +12 -7
  48. package/test/renderers/MaterialRadioGroupControl.test.tsx +2 -2
  49. package/test/renderers/MaterialSliderControl.test.tsx +20 -12
  50. package/test/renderers/MaterialTextCell.test.tsx +10 -7
  51. package/test/renderers/MaterialTimeCell.test.tsx +10 -7
  52. package/test/renderers/MaterialTimeControl.test.tsx +12 -8
@@ -70,23 +70,24 @@ describe('Material boolean toggle control tester', () => {
70
70
  };
71
71
 
72
72
  it('should fail', () => {
73
- expect(materialBooleanToggleControlTester(undefined, undefined)).toBe(
73
+ expect(materialBooleanToggleControlTester(undefined, undefined, undefined)).toBe(
74
74
  NOT_APPLICABLE
75
75
  );
76
- expect(materialBooleanToggleControlTester(null, undefined)).toBe(
76
+ expect(materialBooleanToggleControlTester(null, undefined, undefined)).toBe(
77
77
  NOT_APPLICABLE
78
78
  );
79
- expect(materialBooleanToggleControlTester({ type: 'Foo' }, undefined)).toBe(
79
+ expect(materialBooleanToggleControlTester({ type: 'Foo' }, undefined, undefined)).toBe(
80
80
  NOT_APPLICABLE
81
81
  );
82
82
  expect(
83
- materialBooleanToggleControlTester({ type: 'Control' }, undefined)
83
+ materialBooleanToggleControlTester({ type: 'Control' }, undefined, undefined)
84
84
  ).toBe(NOT_APPLICABLE);
85
85
  expect(
86
86
  materialBooleanToggleControlTester(control, {
87
87
  type: 'object',
88
88
  properties: { foo: { type: 'string' } }
89
- })
89
+ },
90
+ undefined)
90
91
  ).toBe(NOT_APPLICABLE);
91
92
  expect(
92
93
  materialBooleanToggleControlTester(control, {
@@ -99,7 +100,8 @@ describe('Material boolean toggle control tester', () => {
99
100
  type: 'boolean'
100
101
  }
101
102
  }
102
- })
103
+ },
104
+ undefined)
103
105
  ).toBe(NOT_APPLICABLE);
104
106
 
105
107
  // Not applicable for boolean control if toggle option is false
@@ -119,7 +121,8 @@ describe('Material boolean toggle control tester', () => {
119
121
  type: 'boolean'
120
122
  }
121
123
  }
122
- }
124
+ },
125
+ undefined
123
126
  )
124
127
  ).toBe(NOT_APPLICABLE);
125
128
 
@@ -137,7 +140,8 @@ describe('Material boolean toggle control tester', () => {
137
140
  type: 'boolean'
138
141
  }
139
142
  }
140
- }
143
+ },
144
+ undefined
141
145
  )
142
146
  ).toBe(NOT_APPLICABLE);
143
147
  });
@@ -151,7 +155,8 @@ describe('Material boolean toggle control tester', () => {
151
155
  type: 'boolean'
152
156
  }
153
157
  }
154
- })
158
+ },
159
+ undefined)
155
160
  ).toBe(3);
156
161
  });
157
162
  });
@@ -68,11 +68,11 @@ const fixture = {
68
68
 
69
69
  describe('Material categorization layout tester', () => {
70
70
  it('should not fail when given undefined data', () => {
71
- expect(materialCategorizationTester(undefined, undefined)).toBe(-1);
72
- expect(materialCategorizationTester(null, undefined)).toBe(-1);
73
- expect(materialCategorizationTester({ type: 'Foo' }, undefined)).toBe(-1);
71
+ expect(materialCategorizationTester(undefined, undefined, undefined)).toBe(-1);
72
+ expect(materialCategorizationTester(null, undefined, undefined)).toBe(-1);
73
+ expect(materialCategorizationTester({ type: 'Foo' }, undefined, undefined)).toBe(-1);
74
74
  expect(
75
- materialCategorizationTester({ type: 'Categorization' }, undefined)
75
+ materialCategorizationTester({ type: 'Categorization' }, undefined, undefined)
76
76
  ).toBe(-1);
77
77
  });
78
78
 
@@ -81,7 +81,7 @@ describe('Material categorization layout tester', () => {
81
81
  type: 'Categorization',
82
82
  elements: null
83
83
  };
84
- expect(materialCategorizationTester(uischema, undefined)).toBe(-1);
84
+ expect(materialCategorizationTester(uischema, undefined, undefined)).toBe(-1);
85
85
  });
86
86
 
87
87
  it('should succeed with empty elements and no schema', () => {
@@ -89,7 +89,7 @@ describe('Material categorization layout tester', () => {
89
89
  type: 'Categorization',
90
90
  elements: []
91
91
  };
92
- expect(materialCategorizationTester(uischema, undefined)).toBe(1);
92
+ expect(materialCategorizationTester(uischema, undefined, undefined)).toBe(1);
93
93
  });
94
94
 
95
95
  it('should not fail tester with single unknown element and no schema', () => {
@@ -101,7 +101,7 @@ describe('Material categorization layout tester', () => {
101
101
  }
102
102
  ]
103
103
  };
104
- expect(materialCategorizationTester(uischema, undefined)).toBe(-1);
104
+ expect(materialCategorizationTester(uischema, undefined, undefined)).toBe(-1);
105
105
  });
106
106
 
107
107
  it('should succeed with a single category and no schema', () => {
@@ -113,7 +113,7 @@ describe('Material categorization layout tester', () => {
113
113
  }
114
114
  ]
115
115
  };
116
- expect(materialCategorizationTester(categorization, undefined)).toBe(1);
116
+ expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(1);
117
117
  });
118
118
 
119
119
  it('should not apply to a nested categorization with single category and no schema', () => {
@@ -129,7 +129,7 @@ describe('Material categorization layout tester', () => {
129
129
  type: 'Categorization',
130
130
  elements: [nestedCategorization]
131
131
  };
132
- expect(materialCategorizationTester(categorization, undefined)).toBe(-1);
132
+ expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(-1);
133
133
  });
134
134
 
135
135
  it('should not apply to nested categorizations without categories and no schema', () => {
@@ -141,7 +141,7 @@ describe('Material categorization layout tester', () => {
141
141
  }
142
142
  ]
143
143
  };
144
- expect(materialCategorizationTester(categorization, undefined)).toBe(-1);
144
+ expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(-1);
145
145
  });
146
146
 
147
147
  it('should not apply to a nested categorization with null elements and no schema', () => {
@@ -156,7 +156,7 @@ describe('Material categorization layout tester', () => {
156
156
  ]
157
157
  };
158
158
 
159
- expect(materialCategorizationTester(categorization, undefined)).toBe(-1);
159
+ expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(-1);
160
160
  });
161
161
 
162
162
  it('should not apply to a nested categorizations with empty elements and no schema', () => {
@@ -169,7 +169,7 @@ describe('Material categorization layout tester', () => {
169
169
  }
170
170
  ]
171
171
  };
172
- expect(materialCategorizationTester(categorization, undefined)).toBe(-1);
172
+ expect(materialCategorizationTester(categorization, undefined, undefined)).toBe(-1);
173
173
  });
174
174
  });
175
175
 
@@ -68,13 +68,13 @@ const fixture = {
68
68
 
69
69
  describe('Material categorization stepper layout tester', () => {
70
70
  it('should not fail when given undefined data', () => {
71
- expect(materialCategorizationStepperTester(undefined, undefined)).toBe(-1);
72
- expect(materialCategorizationStepperTester(null, undefined)).toBe(-1);
71
+ expect(materialCategorizationStepperTester(undefined, undefined, undefined)).toBe(-1);
72
+ expect(materialCategorizationStepperTester(null, undefined, undefined)).toBe(-1);
73
73
  expect(
74
- materialCategorizationStepperTester({ type: 'Foo' }, undefined)
74
+ materialCategorizationStepperTester({ type: 'Foo' }, undefined, undefined)
75
75
  ).toBe(-1);
76
76
  expect(
77
- materialCategorizationStepperTester({ type: 'Categorization' }, undefined)
77
+ materialCategorizationStepperTester({ type: 'Categorization' }, undefined, undefined)
78
78
  ).toBe(-1);
79
79
  });
80
80
 
@@ -83,7 +83,7 @@ describe('Material categorization stepper layout tester', () => {
83
83
  type: 'Categorization',
84
84
  elements: null
85
85
  };
86
- expect(materialCategorizationStepperTester(uischema, undefined)).toBe(-1);
86
+ expect(materialCategorizationStepperTester(uischema, undefined, undefined)).toBe(-1);
87
87
  });
88
88
 
89
89
  it('should not fail with empty elements and no schema', () => {
@@ -91,7 +91,7 @@ describe('Material categorization stepper layout tester', () => {
91
91
  type: 'Categorization',
92
92
  elements: []
93
93
  };
94
- expect(materialCategorizationStepperTester(uischema, undefined)).toBe(-1);
94
+ expect(materialCategorizationStepperTester(uischema, undefined, undefined)).toBe(-1);
95
95
  });
96
96
 
97
97
  it('should not fail tester with single unknown element and no schema', () => {
@@ -103,7 +103,7 @@ describe('Material categorization stepper layout tester', () => {
103
103
  }
104
104
  ]
105
105
  };
106
- expect(materialCategorizationStepperTester(uischema, undefined)).toBe(-1);
106
+ expect(materialCategorizationStepperTester(uischema, undefined, undefined)).toBe(-1);
107
107
  });
108
108
 
109
109
  it('should not apply to a single category and no schema', () => {
@@ -115,7 +115,7 @@ describe('Material categorization stepper layout tester', () => {
115
115
  }
116
116
  ]
117
117
  };
118
- expect(materialCategorizationStepperTester(categorization, undefined)).toBe(
118
+ expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
119
119
  -1
120
120
  );
121
121
  });
@@ -133,7 +133,7 @@ describe('Material categorization stepper layout tester', () => {
133
133
  type: 'Categorization',
134
134
  elements: [nestedCategorization]
135
135
  };
136
- expect(materialCategorizationStepperTester(categorization, undefined)).toBe(
136
+ expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
137
137
  -1
138
138
  );
139
139
  });
@@ -147,7 +147,7 @@ describe('Material categorization stepper layout tester', () => {
147
147
  }
148
148
  ]
149
149
  };
150
- expect(materialCategorizationStepperTester(categorization, undefined)).toBe(
150
+ expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
151
151
  -1
152
152
  );
153
153
  });
@@ -164,7 +164,7 @@ describe('Material categorization stepper layout tester', () => {
164
164
  ]
165
165
  };
166
166
 
167
- expect(materialCategorizationStepperTester(categorization, undefined)).toBe(
167
+ expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
168
168
  -1
169
169
  );
170
170
  });
@@ -179,7 +179,7 @@ describe('Material categorization stepper layout tester', () => {
179
179
  }
180
180
  ]
181
181
  };
182
- expect(materialCategorizationStepperTester(categorization, undefined)).toBe(
182
+ expect(materialCategorizationStepperTester(categorization, undefined, undefined)).toBe(
183
183
  -1
184
184
  );
185
185
  });
@@ -52,12 +52,12 @@ const uischema: ControlElement = {
52
52
 
53
53
  describe('Material date cell', () => {
54
54
  it('should fail', () => {
55
- expect(materialDateCellTester(undefined, undefined)).toBe(NOT_APPLICABLE);
56
- expect(materialDateCellTester(null, undefined)).toBe(NOT_APPLICABLE);
57
- expect(materialDateCellTester({ type: 'Foo' }, undefined)).toBe(
55
+ expect(materialDateCellTester(undefined, undefined, undefined)).toBe(NOT_APPLICABLE);
56
+ expect(materialDateCellTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
57
+ expect(materialDateCellTester({ type: 'Foo' }, undefined, undefined)).toBe(
58
58
  NOT_APPLICABLE
59
59
  );
60
- expect(materialDateCellTester({ type: 'Control' }, undefined)).toBe(
60
+ expect(materialDateCellTester({ type: 'Control' }, undefined, undefined)).toBe(
61
61
  NOT_APPLICABLE
62
62
  );
63
63
 
@@ -67,7 +67,8 @@ describe('Material date cell', () => {
67
67
  properties: {
68
68
  foo: { type: 'string' }
69
69
  }
70
- })
70
+ },
71
+ undefined)
71
72
  ).toBe(NOT_APPLICABLE);
72
73
  expect(
73
74
  materialDateCellTester(uischema, {
@@ -79,7 +80,8 @@ describe('Material date cell', () => {
79
80
  format: 'date'
80
81
  }
81
82
  }
82
- })
83
+ },
84
+ undefined)
83
85
  ).toBe(NOT_APPLICABLE);
84
86
  });
85
87
 
@@ -93,7 +95,8 @@ describe('Material date cell', () => {
93
95
  format: 'date'
94
96
  }
95
97
  }
96
- })
98
+ },
99
+ undefined)
97
100
  ).toBe(2);
98
101
  });
99
102
  });
@@ -57,14 +57,14 @@ const uischema: ControlElement = {
57
57
 
58
58
  describe('Material date control tester', () => {
59
59
  test('should fail', () => {
60
- expect(materialDateControlTester(undefined, undefined)).toBe(
60
+ expect(materialDateControlTester(undefined, undefined, undefined)).toBe(
61
61
  NOT_APPLICABLE
62
62
  );
63
- expect(materialDateControlTester(null, undefined)).toBe(NOT_APPLICABLE);
64
- expect(materialDateControlTester({ type: 'Foo' }, undefined)).toBe(
63
+ expect(materialDateControlTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
64
+ expect(materialDateControlTester({ type: 'Foo' }, undefined, undefined)).toBe(
65
65
  NOT_APPLICABLE
66
66
  );
67
- expect(materialDateControlTester({ type: 'Control' }, undefined)).toBe(
67
+ expect(materialDateControlTester({ type: 'Control' }, undefined, undefined)).toBe(
68
68
  NOT_APPLICABLE
69
69
  );
70
70
  expect(
@@ -73,7 +73,8 @@ describe('Material date control tester', () => {
73
73
  properties: {
74
74
  foo: { type: 'string' }
75
75
  }
76
- })
76
+ },
77
+ undefined)
77
78
  ).toBe(NOT_APPLICABLE);
78
79
  expect(
79
80
  materialDateControlTester(uischema, {
@@ -85,7 +86,8 @@ describe('Material date control tester', () => {
85
86
  format: 'date'
86
87
  }
87
88
  }
88
- })
89
+ },
90
+ undefined)
89
91
  ).toBe(NOT_APPLICABLE);
90
92
  });
91
93
 
@@ -99,7 +101,8 @@ describe('Material date control tester', () => {
99
101
  format: 'date'
100
102
  }
101
103
  }
102
- })
104
+ },
105
+ undefined)
103
106
  ).toBe(4);
104
107
  expect(
105
108
  materialDateControlTester(
@@ -111,7 +114,8 @@ describe('Material date control tester', () => {
111
114
  type: 'string'
112
115
  }
113
116
  }
114
- }
117
+ },
118
+ undefined
115
119
  )
116
120
  ).toBe(4);
117
121
  });
@@ -58,14 +58,14 @@ const uischema: ControlElement = {
58
58
 
59
59
  describe('Material date time control tester', () => {
60
60
  it('should fail', () => {
61
- expect(materialDateTimeControlTester(undefined, undefined)).toBe(
61
+ expect(materialDateTimeControlTester(undefined, undefined, undefined)).toBe(
62
62
  NOT_APPLICABLE
63
63
  );
64
- expect(materialDateTimeControlTester(null, undefined)).toBe(NOT_APPLICABLE);
65
- expect(materialDateTimeControlTester({ type: 'Foo' }, undefined)).toBe(
64
+ expect(materialDateTimeControlTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
65
+ expect(materialDateTimeControlTester({ type: 'Foo' }, undefined, undefined)).toBe(
66
66
  NOT_APPLICABLE
67
67
  );
68
- expect(materialDateTimeControlTester({ type: 'Control' }, undefined)).toBe(
68
+ expect(materialDateTimeControlTester({ type: 'Control' }, undefined, undefined)).toBe(
69
69
  NOT_APPLICABLE
70
70
  );
71
71
  expect(
@@ -74,7 +74,8 @@ describe('Material date time control tester', () => {
74
74
  properties: {
75
75
  foo: { type: 'string' }
76
76
  }
77
- })
77
+ },
78
+ undefined)
78
79
  ).toBe(NOT_APPLICABLE);
79
80
  expect(
80
81
  materialDateTimeControlTester(uischema, {
@@ -86,7 +87,8 @@ describe('Material date time control tester', () => {
86
87
  format: 'date-time'
87
88
  }
88
89
  }
89
- })
90
+ },
91
+ undefined)
90
92
  ).toBe(NOT_APPLICABLE);
91
93
  });
92
94
 
@@ -100,7 +102,8 @@ describe('Material date time control tester', () => {
100
102
  format: 'date-time'
101
103
  }
102
104
  }
103
- })
105
+ },
106
+ undefined)
104
107
  ).toBe(2);
105
108
  expect(
106
109
  materialDateTimeControlTester(
@@ -112,7 +115,8 @@ describe('Material date time control tester', () => {
112
115
  type: 'string'
113
116
  }
114
117
  }
115
- }
118
+ },
119
+ undefined
116
120
  )
117
121
  ).toBe(2);
118
122
  });
@@ -51,7 +51,8 @@ describe('EnumArrayControl tester', () => {
51
51
  materialEnumArrayRendererTester(uischema, {
52
52
  type: 'array',
53
53
  items: {}
54
- })
54
+ },
55
+ undefined)
55
56
  ).toBe(NOT_APPLICABLE);
56
57
  expect(
57
58
  materialEnumArrayRendererTester(uischema, {
@@ -59,12 +60,13 @@ describe('EnumArrayControl tester', () => {
59
60
  items: {
60
61
  anyOf: []
61
62
  }
62
- })
63
+ },
64
+ undefined)
63
65
  ).toBe(NOT_APPLICABLE);
64
66
  });
65
67
 
66
68
  it('should succeed for schema with enum items', () => {
67
- expect(materialEnumArrayRendererTester(uischema, enumSchema)).toBe(5);
69
+ expect(materialEnumArrayRendererTester(uischema, enumSchema, undefined)).toBe(5);
68
70
  });
69
71
  });
70
72
 
@@ -113,7 +115,7 @@ describe('EnumArrayControl', () => {
113
115
  );
114
116
  const labels = wrapper.find('label');
115
117
  expect(labels.first().text()).toBe('My Title');
116
- expect(labels.last().text()).toBe('Bar');
118
+ expect(labels.last().text()).toBe('bar');
117
119
  });
118
120
 
119
121
  test('oneOf items - updates data', (done) => {
@@ -176,9 +178,9 @@ describe('EnumArrayControl', () => {
176
178
  />
177
179
  );
178
180
  const labels = wrapper.find('label');
179
- expect(labels.at(0).text()).toBe('A');
180
- expect(labels.at(1).text()).toBe('B');
181
- expect(labels.at(2).text()).toBe('C');
181
+ expect(labels.at(0).text()).toBe('a');
182
+ expect(labels.at(1).text()).toBe('b');
183
+ expect(labels.at(2).text()).toBe('c');
182
184
  });
183
185
 
184
186
  test('enum items - updates data', (done) => {
@@ -64,7 +64,8 @@ describe('Material enum cell tester', () => {
64
64
  enum: ['DE', 'IT', 'JP', 'US', 'RU', 'Other']
65
65
  }
66
66
  }
67
- })
67
+ },
68
+ undefined)
68
69
  ).toBe(2);
69
70
  });
70
71
  });
@@ -0,0 +1,75 @@
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 './MatchMediaMock';
26
+ import * as React from 'react';
27
+ import {
28
+ ControlElement
29
+ } from '@jsonforms/core';
30
+ import { materialRenderers, MuiSelect } from '../../src';
31
+
32
+ import Enzyme, { mount } from 'enzyme';
33
+ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
34
+ import { JsonFormsStateProvider } from '@jsonforms/react';
35
+ import { initCore } from './util';
36
+ import { MaterialEnumControl } from '../../src';
37
+
38
+ Enzyme.configure({ adapter: new Adapter() });
39
+
40
+ const data = { nationality: 'JP' };
41
+ const schema = {
42
+ type: 'string',
43
+ enum: ['DE', 'IT', 'JP', 'US', 'RU', 'Other']
44
+ };
45
+ const uischema: ControlElement = {
46
+ type: 'Control',
47
+ scope: '#/properties/nationality',
48
+ options: {
49
+ autocomplete: false
50
+ }
51
+ };
52
+
53
+ describe('Material enum control', () => {
54
+ it('enum options should change when translation changes', () => {
55
+ const core = initCore(schema, uischema, data);
56
+ const translate = () => 'Translated';
57
+ const changedTranslate = () => 'OtherTranslation';
58
+ const wrapper = mount(
59
+ <JsonFormsStateProvider initState={{ renderers: materialRenderers, core, i18n: {translate} }}>
60
+ <MaterialEnumControl
61
+ schema={schema}
62
+ uischema={uischema}
63
+ path='nationality'
64
+ />
65
+ </JsonFormsStateProvider>
66
+ );
67
+
68
+ expect(wrapper.find(MuiSelect).props().options[0].label).toBe('Translated');
69
+
70
+ wrapper.setProps({ initState: { renderers: materialRenderers, core, i18n: {translate: changedTranslate} }} );
71
+ wrapper.update();
72
+
73
+ expect(wrapper.find(MuiSelect).props().options[0].label).toBe('OtherTranslation');
74
+ });
75
+ });
@@ -57,27 +57,29 @@ describe('Material integer cells tester', () => {
57
57
  };
58
58
 
59
59
  it('should fail', () => {
60
- expect(materialIntegerCellTester(undefined, undefined)).toBe(
60
+ expect(materialIntegerCellTester(undefined, undefined, undefined)).toBe(
61
61
  NOT_APPLICABLE
62
62
  );
63
- expect(materialIntegerCellTester(null, undefined)).toBe(NOT_APPLICABLE);
64
- expect(materialIntegerCellTester({ type: 'Foo' }, undefined)).toBe(
63
+ expect(materialIntegerCellTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
64
+ expect(materialIntegerCellTester({ type: 'Foo' }, undefined, undefined)).toBe(
65
65
  NOT_APPLICABLE
66
66
  );
67
- expect(materialIntegerCellTester({ type: 'Control' }, undefined)).toBe(
67
+ expect(materialIntegerCellTester({ type: 'Control' }, undefined, undefined)).toBe(
68
68
  NOT_APPLICABLE
69
69
  );
70
70
  expect(
71
71
  materialIntegerCellTester(controlElement, {
72
72
  type: 'object',
73
73
  properties: { foo: { type: 'string' } }
74
- })
74
+ },
75
+ undefined)
75
76
  ).toBe(NOT_APPLICABLE);
76
77
  expect(
77
78
  materialIntegerCellTester(controlElement, {
78
79
  type: 'object',
79
80
  properties: { foo: { type: 'string' }, bar: { type: 'integer' } }
80
- })
81
+ },
82
+ undefined)
81
83
  ).toBe(NOT_APPLICABLE);
82
84
  });
83
85
 
@@ -86,7 +88,8 @@ describe('Material integer cells tester', () => {
86
88
  materialIntegerCellTester(controlElement, {
87
89
  type: 'object',
88
90
  properties: { foo: { type: 'integer' } }
89
- })
91
+ },
92
+ undefined)
90
93
  ).toBe(2);
91
94
  });
92
95
  });
@@ -51,14 +51,14 @@ const uischema = {
51
51
 
52
52
  describe('Material Label Renderer tester', () => {
53
53
  it('should fail', () => {
54
- expect(materialLabelRendererTester(undefined, undefined)).toBe(
54
+ expect(materialLabelRendererTester(undefined, undefined, undefined)).toBe(
55
55
  NOT_APPLICABLE
56
56
  );
57
- expect(materialLabelRendererTester(null, undefined)).toBe(NOT_APPLICABLE);
58
- expect(materialLabelRendererTester({ type: 'Foo' }, undefined)).toBe(
57
+ expect(materialLabelRendererTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
58
+ expect(materialLabelRendererTester({ type: 'Foo' }, undefined, undefined)).toBe(
59
59
  NOT_APPLICABLE
60
60
  );
61
- expect(materialLabelRendererTester({ type: 'Label' }, undefined)).toBe(1);
61
+ expect(materialLabelRendererTester({ type: 'Label' }, undefined, undefined)).toBe(1);
62
62
  });
63
63
  });
64
64
 
@@ -110,13 +110,13 @@ describe('Material list with detail tester', () => {
110
110
  type: 'string'
111
111
  }
112
112
  };
113
- expect(materialListWithDetailTester(uischema, schema)).toBe(-1);
114
- expect(materialListWithDetailTester(correctUISchema, wrongSchema)).toBe(-1);
115
- expect(materialListWithDetailTester(correctUISchema, schema)).toBe(4);
116
- expect(materialListWithDetailTester(correctUISchema, nestedSchema)).toBe(
113
+ expect(materialListWithDetailTester(uischema, schema, undefined)).toBe(-1);
114
+ expect(materialListWithDetailTester(correctUISchema, wrongSchema, undefined)).toBe(-1);
115
+ expect(materialListWithDetailTester(correctUISchema, schema, undefined)).toBe(4);
116
+ expect(materialListWithDetailTester(correctUISchema, nestedSchema, undefined)).toBe(
117
117
  -1
118
118
  );
119
- expect(materialListWithDetailTester(correctUISchema, nestedSchema2)).toBe(
119
+ expect(materialListWithDetailTester(correctUISchema, nestedSchema2, undefined)).toBe(
120
120
  4
121
121
  );
122
122
  });
@@ -52,12 +52,12 @@ const uischema: ControlElement = {
52
52
 
53
53
  describe('Material number cells tester', () => {
54
54
  it('should fail', () => {
55
- expect(materialNumberCellTester(undefined, undefined)).toBe(NOT_APPLICABLE);
56
- expect(materialNumberCellTester(null, undefined)).toBe(NOT_APPLICABLE);
57
- expect(materialNumberCellTester({ type: 'Foo' }, undefined)).toBe(
55
+ expect(materialNumberCellTester(undefined, undefined, undefined)).toBe(NOT_APPLICABLE);
56
+ expect(materialNumberCellTester(null, undefined, undefined)).toBe(NOT_APPLICABLE);
57
+ expect(materialNumberCellTester({ type: 'Foo' }, undefined, undefined)).toBe(
58
58
  NOT_APPLICABLE
59
59
  );
60
- expect(materialNumberCellTester({ type: 'Control' }, undefined)).toBe(
60
+ expect(materialNumberCellTester({ type: 'Control' }, undefined, undefined)).toBe(
61
61
  NOT_APPLICABLE
62
62
  );
63
63
  });
@@ -75,7 +75,8 @@ describe('Material number cells tester', () => {
75
75
  type: 'string'
76
76
  }
77
77
  }
78
- })
78
+ },
79
+ undefined)
79
80
  ).toBe(NOT_APPLICABLE);
80
81
  });
81
82
 
@@ -95,7 +96,8 @@ describe('Material number cells tester', () => {
95
96
  type: 'number'
96
97
  }
97
98
  }
98
- })
99
+ },
100
+ undefined)
99
101
  ).toBe(NOT_APPLICABLE);
100
102
  });
101
103
 
@@ -112,7 +114,8 @@ describe('Material number cells tester', () => {
112
114
  type: 'number'
113
115
  }
114
116
  }
115
- })
117
+ },
118
+ undefined)
116
119
  ).toBe(2);
117
120
  });
118
121
  });