Skip to content

Commit 5a51102

Browse files
committed
fix: all tests passing
1 parent eb8a2c2 commit 5a51102

File tree

31 files changed

+1594
-1292
lines changed

31 files changed

+1594
-1292
lines changed

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module.exports = {
1616
// All type definitions to be excluded
1717
'!*.d.ts',
1818
'!*.type.ts',
19+
// Ingore Mobile files - will be covered seperately
20+
'!*.native.ts',
21+
'!*.native.tsx',
1922
// All Ignore files should be covered by E2E Tests to get maximum coverage.
2023
'<rootDir>/node_modules',
2124
// Ignore Demo folder

scripts/generator/components.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
]
6565
},
6666
"@react-jsonschema-form-components/material-auto-complete": {
67-
"version": "3.0.0",
67+
"version": "3.0.1",
6868
"type": "string",
6969
"isEnum": true,
7070
"name": "material-auto-complete",
@@ -74,7 +74,7 @@
7474
]
7575
},
7676
"@react-jsonschema-form-components/material-checkbox": {
77-
"version": "3.0.0",
77+
"version": "3.0.1",
7878
"type": "string",
7979
"isEnum": true,
8080
"isRequired": true,

src/FieldSet/FieldSetStepper.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React from 'react';
33

44
// Material UI
5+
import { Theme } from '@mui/material/styles';
56
import { makeStyles } from '@mui/styles';
67
import Stepper from '@mui/material/Stepper';
78
import Step from '@mui/material/Step';
@@ -15,7 +16,7 @@ import { StepperContext } from '../helpers/context';
1516
// Internal
1617
import FieldSetObject from './FieldSetObject';
1718

18-
const useStyles = makeStyles((theme) => ({
19+
const useStyles = makeStyles((theme: Theme) => ({
1920
root: {
2021
width: '100%',
2122
},

src/FieldSet/__tests__/FieldSet.spec.tsx

Lines changed: 128 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// Library
22
import React from 'react';
3-
import { shallow, mount } from 'enzyme';
3+
import { mountTheme, shallowTheme } from '../../helpers/enzyme-unit-test';
44

55
// Material UI
6-
import { ThemeProvider, createTheme } from '@mui/material/styles';
76
import IconButton from '@mui/material/IconButton';
87

98
// Internal
@@ -28,21 +27,21 @@ describe('FieldSet', () => {
2827
const data = {};
2928

3029
// act
31-
const wrapper = mount(
32-
<ThemeProvider theme={createTheme()}>
33-
<RawFieldSet
34-
classes={{ root }}
35-
schema={schema}
36-
data={data}
37-
path={'path'}
38-
uiSchema={{}}
39-
xhrSchema={{}}
40-
onKeyDown={jest.fn}
41-
onChange={jest.fn}
42-
onXHRSchemaEvent={jest.fn}
43-
/>
44-
</ThemeProvider>,
45-
);
30+
const wrapper = mountTheme({
31+
component: (
32+
<RawFieldSet
33+
classes={{ root }}
34+
schema={schema}
35+
data={data}
36+
path={'path'}
37+
uiSchema={{}}
38+
xhrSchema={{}}
39+
onKeyDown={jest.fn}
40+
onChange={jest.fn}
41+
onXHRSchemaEvent={jest.fn}
42+
/>
43+
)
44+
});
4645

4746
// check
4847
expect(wrapper).toHaveLength(1);
@@ -69,26 +68,26 @@ describe('FieldSet', () => {
6968
const data = { name: 'Bob' };
7069

7170
// act
72-
const wrapper = mount(
73-
<ThemeProvider theme={createTheme()}>
71+
const wrapper = mountTheme({
72+
component: (
7473
<RawFieldSetObject
75-
classes={{ row }}
76-
schema={schema}
77-
data={data}
78-
path={''}
79-
uiSchema={{}}
80-
xhrSchema={{}}
81-
onKeyDown={jest.fn}
82-
onChange={jest.fn}
83-
onXHRSchemaEvent={jest.fn}
84-
id={'1'}
85-
idxKey={'1'}
86-
validation={{}}
87-
isTabContent={false}
88-
tabKey={''}
74+
classes={{ row }}
75+
schema={schema}
76+
data={data}
77+
path={''}
78+
uiSchema={{}}
79+
xhrSchema={{}}
80+
onKeyDown={jest.fn}
81+
onChange={jest.fn}
82+
onXHRSchemaEvent={jest.fn}
83+
id={'1'}
84+
idxKey={'1'}
85+
validation={{}}
86+
isTabContent={false}
87+
tabKey={''}
8988
/>
90-
</ThemeProvider>,
91-
);
89+
)
90+
});
9291

9392
// check
9493
expect(wrapper).toHaveLength(1);
@@ -113,8 +112,8 @@ describe('FieldSet', () => {
113112
const data = { name: 'Bob' };
114113

115114
// act
116-
const wrapper = mount(
117-
<ThemeProvider theme={createTheme()}>
115+
const wrapper = mountTheme({
116+
component: (
118117
<RawFieldSetObject
119118
classes={{ row }}
120119
schema={schema}
@@ -131,8 +130,8 @@ describe('FieldSet', () => {
131130
isTabContent={false}
132131
tabKey={''}
133132
/>
134-
</ThemeProvider>,
135-
);
133+
)
134+
});
136135

137136
// check
138137
expect(wrapper).toHaveLength(1);
@@ -159,26 +158,28 @@ describe('FieldSet', () => {
159158
const data = { name: 'Bob' };
160159

161160
// act
162-
const wrapper = shallow(
163-
<ThemeProvider theme={createTheme()}>
161+
const parent = shallowTheme({
162+
component: (
164163
<RawFieldSetObject
165-
classes={{ row }}
166-
schema={schema}
167-
data={data}
168-
uiSchema={uiSchema}
169-
path={''}
170-
xhrSchema={{}}
171-
onKeyDown={jest.fn}
172-
onChange={jest.fn}
173-
onXHRSchemaEvent={jest.fn}
174-
id={'1'}
175-
idxKey={'1'}
176-
validation={{}}
177-
isTabContent={false}
178-
tabKey={''}
164+
classes={{ row }}
165+
schema={schema}
166+
data={data}
167+
uiSchema={uiSchema}
168+
path={''}
169+
xhrSchema={{}}
170+
onKeyDown={jest.fn}
171+
onChange={jest.fn}
172+
onXHRSchemaEvent={jest.fn}
173+
id={'1'}
174+
idxKey={'1'}
175+
validation={{}}
176+
isTabContent={false}
177+
tabKey={''}
179178
/>
180-
</ThemeProvider>,
181-
);
179+
)
180+
});
181+
182+
const wrapper = parent.find('RawFieldSetObject').dive();
182183

183184
// check
184185
expect(wrapper).toHaveLength(1);
@@ -222,8 +223,8 @@ describe('FieldSet', () => {
222223
const onAddItem = jest.fn();
223224

224225
// act
225-
const wrapper = shallow(
226-
<ThemeProvider theme={createTheme()}>
226+
const parent = shallowTheme({
227+
component: (
227228
<RawFieldSetArray
228229
startIdx={startIdx}
229230
onAddItem={onAddItem}
@@ -236,8 +237,10 @@ describe('FieldSet', () => {
236237
schema={schema}
237238
data={data}
238239
/>
239-
</ThemeProvider>,
240-
);
240+
)
241+
});
242+
243+
const wrapper = parent.find('RawFieldSetArray').dive();
241244

242245
// check
243246
expect(wrapper).toHaveLength(1);
@@ -286,17 +289,19 @@ describe('FieldSet', () => {
286289
const data = ['Bob', false];
287290

288291
// act
289-
const wrapper = shallow(
290-
<ThemeProvider theme={createTheme()}>
292+
const parent = shallowTheme({
293+
component: (
291294
<RawFieldSetArray
292295
uiSchema={uiSchema}
293296
path={path}
294297
classes={{ row }}
295298
schema={schema}
296299
data={data}
297300
/>
298-
</ThemeProvider>,
299-
);
301+
)
302+
});
303+
304+
const wrapper = parent.find('RawFieldSetArray').dive();
300305

301306
// check
302307
expect(wrapper).toHaveLength(1);
@@ -346,8 +351,8 @@ describe('FieldSet', () => {
346351
const data = ['Bob', false, 'Harry', 'Susan'];
347352

348353
// act
349-
const wrapper = shallow(
350-
<ThemeProvider theme={createTheme()}>
354+
const parent = shallowTheme({
355+
component: (
351356
<RawFieldSetArray
352357
onMoveItemUp={onMoveItemUp}
353358
onMoveItemDown={onMoveItemDown}
@@ -358,8 +363,10 @@ describe('FieldSet', () => {
358363
schema={schema}
359364
data={data}
360365
/>
361-
</ThemeProvider>,
362-
);
366+
)
367+
});
368+
369+
const wrapper = parent.find('RawFieldSetArray').dive();
363370

364371
// check
365372
expect(wrapper).toHaveLength(1);
@@ -396,17 +403,22 @@ describe('FieldSet', () => {
396403
const onDeleteItem = jest.fn();
397404

398405
// act
399-
const wrapper = shallow(
400-
<RawReorderControls
401-
onMoveItemDown={onMoveItemDown}
402-
onDeleteItem={onDeleteItem}
403-
onMoveItemUp={onMoveItemUp}
404-
classes={{ row }}
405-
first
406-
last={false}
407-
canReorder
408-
/>,
409-
);
406+
const parent = shallowTheme({
407+
component: (
408+
<RawReorderControls
409+
onMoveItemDown={onMoveItemDown}
410+
onDeleteItem={onDeleteItem}
411+
onMoveItemUp={onMoveItemUp}
412+
classes={{ row }}
413+
first
414+
last={false}
415+
canReorder
416+
/>
417+
)
418+
});
419+
420+
const wrapper = parent.find('RawReorderControls').dive();
421+
410422
// check
411423
expect(wrapper).toHaveLength(1);
412424
const buttonList = wrapper.find(IconButton);
@@ -420,9 +432,18 @@ describe('FieldSet', () => {
420432
});
421433
it('ReorderControls - first', () => {
422434
// act
423-
const wrapper = shallow(
424-
<RawReorderControls first last={false} classes={{ row }} canReorder />,
425-
);
435+
const parent = shallowTheme({
436+
component: (
437+
<RawReorderControls
438+
first
439+
last={false}
440+
classes={{ row }}
441+
canReorder
442+
/>
443+
)
444+
});
445+
446+
const wrapper = parent.find('RawReorderControls').dive();
426447

427448
// check
428449
expect(wrapper).toHaveLength(1);
@@ -434,9 +455,18 @@ describe('FieldSet', () => {
434455
});
435456
it('ReorderControls - last', () => {
436457
// act
437-
const wrapper = shallow(
438-
<RawReorderControls first={false} last classes={{ row }} canReorder />,
439-
);
458+
const parent = shallowTheme({
459+
component: (
460+
<RawReorderControls
461+
first={false}
462+
last
463+
classes={{ row }}
464+
canReorder
465+
/>
466+
)
467+
});
468+
469+
const wrapper = parent.find('RawReorderControls').dive();
440470

441471
// check
442472
expect(wrapper).toHaveLength(1);
@@ -454,14 +484,18 @@ describe('FieldSet', () => {
454484
const first = true;
455485
const last = false;
456486
// act
457-
const wrapper = shallow(
458-
<RawReorderableFormField
459-
path={path}
460-
first={first}
461-
last={last}
462-
classes={{ row }}
463-
/>,
464-
);
487+
const parent = shallowTheme({
488+
component: (
489+
<RawReorderableFormField
490+
path={path}
491+
first={first}
492+
last={last}
493+
classes={{ row }}
494+
/>
495+
)
496+
});
497+
498+
const wrapper = parent.find('RawReorderableFormField').dive();
465499

466500
// check
467501
const ffComp = wrapper.find(FormField);

0 commit comments

Comments
 (0)