@arquimedes.co/eureka-forms 2.0.24-test → 2.0.25-test
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/@Types/Form.d.ts +1 -1
- package/dist/@Types/FormStep.d.ts +0 -1
- package/dist/Form/Form.js +1 -1
- package/dist/Form/FormFunctions.d.ts +3 -0
- package/dist/Form/FormFunctions.js +19 -17
- package/dist/FormSteps/StepFunctions.d.ts +2 -2
- package/dist/FormSteps/StepFunctions.js +1 -1
- package/dist/Utils/TestUtils.d.ts +77 -0
- package/dist/Utils/TestUtils.js +65 -0
- package/dist/Utils/store.d.ts +2 -0
- package/dist/Utils/store.js +1 -1
- package/dist/__mocks__/axios.d.ts +2 -0
- package/dist/__mocks__/axios.js +2 -0
- package/package.json +12 -1
- /package/dist/Form/{Hooks.d.ts → FormHooks.d.ts} +0 -0
- /package/dist/Form/{Hooks.js → FormHooks.js} +0 -0
package/dist/@Types/Form.d.ts
CHANGED
package/dist/Form/Form.js
CHANGED
|
@@ -62,7 +62,7 @@ import axiosInstance from '../Utils/AxiosAPI';
|
|
|
62
62
|
import ReCAPTCHA from 'react-google-recaptcha';
|
|
63
63
|
import ConfirmationDialog from './ConfirmationDialog/ConfirmationDialog';
|
|
64
64
|
import MaterialProviders from '../Utils/MaterialProviders';
|
|
65
|
-
import { useWidthStats } from './
|
|
65
|
+
import { useWidthStats } from './FormHooks';
|
|
66
66
|
import { IdFormContext } from '../App/App';
|
|
67
67
|
import { useAppDispatch, useAppSelector } from '../hooks';
|
|
68
68
|
import FormContext from '../Contexts/FormContext';
|
|
@@ -4,6 +4,9 @@ import { CustomStep } from '../FormSteps/CustomStep';
|
|
|
4
4
|
import { CBRFormStep } from '../@Types/CBRFormStep';
|
|
5
5
|
import { MapperElement } from '../@Types/MapperElement';
|
|
6
6
|
import { ValuesStore } from '../States/SiteSlice';
|
|
7
|
+
/**
|
|
8
|
+
* Function that cals the value of a step to output on submit
|
|
9
|
+
*/
|
|
7
10
|
export declare const calcValue: (idStep: string, steps: Record<string, FormStep>, values: Record<string, any>, customSteps: Record<string, CustomStep> | undefined, deleteIds: string[], value?: any) => any;
|
|
8
11
|
export declare function calcDependencies(steps: Record<string, FormStep | CBRFormStep>, customSteps?: Record<string, CustomStep>, allSteps?: Record<string, FormStep | CBRFormStep>, dependencies?: DependencyStore, values?: ValuesStore, addDependents?: boolean): DependencyStore;
|
|
9
12
|
export declare const calcMapperSubSteps: (step: Mapper, elements: MapperElement<any>[] | undefined, customSteps: Record<string, CustomStep>) => Record<string, FormStep>;
|
|
@@ -18,9 +18,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
18
18
|
}
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
|
-
import { convertToRaw } from 'draft-js';
|
|
21
|
+
import { convertFromRaw, convertToRaw } from 'draft-js';
|
|
22
22
|
import StepTypes, { EntityValueDataTypes } from '../constants/FormStepTypes';
|
|
23
23
|
import { calcRecursiveData } from '../App/AppFunctions';
|
|
24
|
+
/**
|
|
25
|
+
* Function that cals the value of a step to output on submit
|
|
26
|
+
*/
|
|
24
27
|
export var calcValue = function (idStep, steps, values, customSteps, deleteIds, value) {
|
|
25
28
|
var _a, _b;
|
|
26
29
|
if (value === void 0) { value = values[idStep]; }
|
|
@@ -32,7 +35,7 @@ export var calcValue = function (idStep, steps, values, customSteps, deleteIds,
|
|
|
32
35
|
return (_b = (_a = custom.calcValue) === null || _a === void 0 ? void 0 : _a.call(custom, step, value)) !== null && _b !== void 0 ? _b : value;
|
|
33
36
|
}
|
|
34
37
|
else {
|
|
35
|
-
switch (step
|
|
38
|
+
switch (step.type) {
|
|
36
39
|
case StepTypes.TEXTAREA: {
|
|
37
40
|
if (step.hasTextEditor) {
|
|
38
41
|
var currentContent = value.getCurrentContent();
|
|
@@ -58,9 +61,6 @@ export var calcValue = function (idStep, steps, values, customSteps, deleteIds,
|
|
|
58
61
|
case StepTypes.CLASSIFIER_SELECTOR: {
|
|
59
62
|
return value.value;
|
|
60
63
|
}
|
|
61
|
-
case StepTypes.COLLAPSIBLE: {
|
|
62
|
-
return !!value;
|
|
63
|
-
}
|
|
64
64
|
case StepTypes.MAPPER: {
|
|
65
65
|
var elements = value === null || value === void 0 ? void 0 : value.filter(function (element) { return element.deleted !== true; });
|
|
66
66
|
var mappedValues = [];
|
|
@@ -88,6 +88,7 @@ export var calcValue = function (idStep, steps, values, customSteps, deleteIds,
|
|
|
88
88
|
return mappedValues;
|
|
89
89
|
}
|
|
90
90
|
case StepTypes.TITLE:
|
|
91
|
+
case StepTypes.COLLAPSIBLE:
|
|
91
92
|
deleteIds.push(idStep);
|
|
92
93
|
return;
|
|
93
94
|
default:
|
|
@@ -128,7 +129,6 @@ export function calcDependencies(steps, customSteps, allSteps, dependencies, val
|
|
|
128
129
|
if (addDependents === void 0) { addDependents = true; }
|
|
129
130
|
for (var _i = 0, _c = Object.values(steps); _i < _c.length; _i++) {
|
|
130
131
|
var step = _c[_i];
|
|
131
|
-
var originalValue = (_a = values.sections[step.idSection]) === null || _a === void 0 ? void 0 : _a[step.id];
|
|
132
132
|
if (step.dependencies) {
|
|
133
133
|
for (var _d = 0, _e = step.dependencies; _d < _e.length; _d++) {
|
|
134
134
|
var idDep = _e[_d];
|
|
@@ -144,7 +144,7 @@ export function calcDependencies(steps, customSteps, allSteps, dependencies, val
|
|
|
144
144
|
var dep = _g[_f];
|
|
145
145
|
if (dep.type !== EntityValueDataTypes.STEP)
|
|
146
146
|
continue;
|
|
147
|
-
if ((
|
|
147
|
+
if ((_a = step.dependencies) === null || _a === void 0 ? void 0 : _a.includes(dep.idStep))
|
|
148
148
|
continue;
|
|
149
149
|
if (dependencies[dep.idStep] === undefined &&
|
|
150
150
|
(addDependents || allSteps[dep.idStep])) {
|
|
@@ -155,7 +155,7 @@ export function calcDependencies(steps, customSteps, allSteps, dependencies, val
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
if (step.type === StepTypes.MAPPER) {
|
|
158
|
-
var subSteps = calcMapperSubSteps(step,
|
|
158
|
+
var subSteps = calcMapperSubSteps(step, (_b = values.sections[step.idSection]) === null || _b === void 0 ? void 0 : _b[step.id], customSteps);
|
|
159
159
|
var hasSubSteps = Object.keys(subSteps).length > 0;
|
|
160
160
|
calcDependencies(hasSubSteps ? subSteps : step.steps, customSteps, __assign(__assign({}, allSteps), subSteps), dependencies, values, hasSubSteps);
|
|
161
161
|
}
|
|
@@ -182,22 +182,21 @@ export var calcMapperSubSteps = function (step, elements, customSteps) {
|
|
|
182
182
|
return newSteps;
|
|
183
183
|
};
|
|
184
184
|
function calcStepDependency(idStep, steps, values, customSteps) {
|
|
185
|
-
var _a
|
|
185
|
+
var _a;
|
|
186
186
|
var depStep = steps[idStep];
|
|
187
187
|
if (!depStep) {
|
|
188
188
|
console.error('Missing Step Dependency:', idStep);
|
|
189
|
+
var originalValue_1 = values.global[idStep];
|
|
189
190
|
return {
|
|
190
|
-
type: 'MISSING',
|
|
191
|
-
value: null,
|
|
191
|
+
type: originalValue_1 ? 'ORIGINAL' : 'MISSING',
|
|
192
|
+
value: originalValue_1 !== null && originalValue_1 !== void 0 ? originalValue_1 : null,
|
|
192
193
|
dependents: [],
|
|
193
194
|
};
|
|
194
195
|
}
|
|
195
196
|
var originalValue = (_a = values.sections[depStep.idSection]) === null || _a === void 0 ? void 0 : _a[depStep.id];
|
|
196
197
|
return {
|
|
197
|
-
type:
|
|
198
|
-
value: depStep
|
|
199
|
-
? calcStepDependencyValue(depStep, originalValue, customSteps)
|
|
200
|
-
: originalValue !== null && originalValue !== void 0 ? originalValue : null,
|
|
198
|
+
type: depStep.type,
|
|
199
|
+
value: calcStepDependencyValue(depStep, originalValue, customSteps),
|
|
201
200
|
dependents: [],
|
|
202
201
|
};
|
|
203
202
|
}
|
|
@@ -210,13 +209,16 @@ function calcStepDependencyValue(depStep, originalValue, customSteps) {
|
|
|
210
209
|
switch (depStep.type) {
|
|
211
210
|
case StepTypes.TEXTAREA: {
|
|
212
211
|
if (depStep.hasTextEditor) {
|
|
213
|
-
return
|
|
212
|
+
return originalValue
|
|
213
|
+
? convertFromRaw(originalValue).getPlainText()
|
|
214
|
+
: null;
|
|
214
215
|
}
|
|
215
216
|
else {
|
|
216
|
-
return originalValue
|
|
217
|
+
return originalValue !== null && originalValue !== void 0 ? originalValue : null;
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
case StepTypes.MAPPER: {
|
|
221
|
+
//TODO: Esto aun no se usa
|
|
220
222
|
return ((_a = originalValue === null || originalValue === void 0 ? void 0 : originalValue.map(function (mapperValue) { var _a; return (_a = mapperValue.value) !== null && _a !== void 0 ? _a : mapperValue; })) !== null && _a !== void 0 ? _a : null);
|
|
221
223
|
}
|
|
222
224
|
default:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FormSize } from '../@Types/Form';
|
|
2
2
|
import { ApiSelector, CheckBox, ClassifierSelector, EntityValuePicker, FormSelector, FormStep } from '../@Types/FormStep';
|
|
3
|
+
import { AYFFormStep } from '../@Types/AYFFormStep';
|
|
3
4
|
import { CBRFormStep } from '../@Types/CBRFormStep';
|
|
4
5
|
export type FillerSteps = FormSelector | ClassifierSelector | EntityValuePicker | ApiSelector | CheckBox;
|
|
5
6
|
export declare function calcFillerSize(step: FillerSteps, steps: Record<string, FormStep>, values: Record<string, unknown>, size: FormSize): number;
|
|
6
|
-
export declare function recursivelyCheckOpenSize(idStep: string, steps: Record<string, FormStep>, values: Record<string, any>): number;
|
|
7
7
|
export declare const calcStepWidth: (stepSize: 1 | 2 | 3 | 4, size: FormSize) => number;
|
|
8
8
|
export declare const calcDefaultValue: (step: FormStep | CBRFormStep) => any;
|
|
9
9
|
export declare const iterateNestedSteps: (idStep: string, steps: Record<string, FormStep>, iteration: (step: FormStep) => void) => void;
|
|
@@ -13,4 +13,4 @@ export declare const iterateNestedSteps: (idStep: string, steps: Record<string,
|
|
|
13
13
|
* @param idModifier optional modifier for the ids of the substeps and all other properties
|
|
14
14
|
* @returns list of the ids of the direct substeps of the step, if modifier returns modified steps
|
|
15
15
|
*/
|
|
16
|
-
export declare const calcSubSteps: (step: FormStep, idModifier?: ((idSubStep: string) => string) | undefined) => string[];
|
|
16
|
+
export declare const calcSubSteps: (step: FormStep | CBRFormStep | AYFFormStep, idModifier?: ((idSubStep: string) => string) | undefined) => string[];
|
|
@@ -14,7 +14,7 @@ export function calcFillerSize(step, steps, values, size) {
|
|
|
14
14
|
return 0;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
function recursivelyCheckOpenSize(idStep, steps, values) {
|
|
18
18
|
var step = steps[idStep];
|
|
19
19
|
var value = values[idStep];
|
|
20
20
|
switch (step.type) {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RenderOptions } from '@testing-library/react';
|
|
3
|
+
import { AppStore } from './store';
|
|
4
|
+
import { RenderHookOptions } from '@testing-library/react-hooks';
|
|
5
|
+
interface ExtendedRenderOptions extends Omit<RenderOptions, 'queries'> {
|
|
6
|
+
store?: AppStore;
|
|
7
|
+
}
|
|
8
|
+
export declare function renderWithProviders(ui: React.ReactElement, { store, ...renderOptions }?: ExtendedRenderOptions): {
|
|
9
|
+
container: HTMLElement;
|
|
10
|
+
baseElement: HTMLElement;
|
|
11
|
+
debug: (baseElement?: Element | DocumentFragment | (Element | DocumentFragment)[] | undefined, maxLength?: number | undefined, options?: import("pretty-format").PrettyFormatOptions | undefined) => void;
|
|
12
|
+
rerender: (ui: React.ReactElement<any, string | React.JSXElementConstructor<any>>) => void;
|
|
13
|
+
unmount: () => void;
|
|
14
|
+
asFragment: () => DocumentFragment;
|
|
15
|
+
getByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement;
|
|
16
|
+
getAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
17
|
+
queryByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
18
|
+
queryAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
19
|
+
findByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
20
|
+
findAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
21
|
+
getByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
|
|
22
|
+
getAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
23
|
+
queryByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
|
|
24
|
+
queryAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
25
|
+
findByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
26
|
+
findAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
27
|
+
getByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement;
|
|
28
|
+
getAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
29
|
+
queryByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
30
|
+
queryAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
31
|
+
findByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
32
|
+
findAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
33
|
+
getByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
|
|
34
|
+
getAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
35
|
+
queryByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
|
|
36
|
+
queryAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
37
|
+
findByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
38
|
+
findAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
39
|
+
getByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
|
|
40
|
+
getAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
41
|
+
queryByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
|
|
42
|
+
queryAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
43
|
+
findByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
44
|
+
findAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
45
|
+
getByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
|
|
46
|
+
getAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
47
|
+
queryByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
|
|
48
|
+
queryAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
49
|
+
findByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
50
|
+
findAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
51
|
+
getByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement;
|
|
52
|
+
getAllByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement[];
|
|
53
|
+
queryByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement | null;
|
|
54
|
+
queryAllByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement[];
|
|
55
|
+
findByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
56
|
+
findAllByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
57
|
+
getByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
|
|
58
|
+
getAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
59
|
+
queryByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
|
|
60
|
+
queryAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
|
|
61
|
+
findByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
62
|
+
findAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
63
|
+
store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<import("./store").EurekaFormsState, import("redux").AnyAction, [import("@reduxjs/toolkit").ThunkMiddleware<import("./store").EurekaFormsState, import("redux").AnyAction, undefined>]>;
|
|
64
|
+
};
|
|
65
|
+
interface ExtendedRenderHookOptions<TProps> extends Omit<RenderHookOptions<TProps>, 'wrapper'> {
|
|
66
|
+
store?: AppStore;
|
|
67
|
+
}
|
|
68
|
+
export declare function renderHookWithProviders<TProps, TResult>(callback: (props: TProps) => TResult, { store, ...renderHookOptions }?: ExtendedRenderHookOptions<TProps>): {
|
|
69
|
+
result: import("@testing-library/react-hooks").RenderResult<TResult>;
|
|
70
|
+
rerender: (props?: TProps | undefined) => void;
|
|
71
|
+
unmount: () => void;
|
|
72
|
+
waitFor: import("@testing-library/react-hooks").WaitFor;
|
|
73
|
+
waitForValueToChange: import("@testing-library/react-hooks").WaitForValueToChange;
|
|
74
|
+
waitForNextUpdate: import("@testing-library/react-hooks").WaitForNextUpdate;
|
|
75
|
+
store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<import("./store").EurekaFormsState, import("redux").AnyAction, [import("@reduxjs/toolkit").ThunkMiddleware<import("./store").EurekaFormsState, import("redux").AnyAction, undefined>]>;
|
|
76
|
+
};
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import React from 'react';
|
|
25
|
+
import { render } from '@testing-library/react';
|
|
26
|
+
import { configureStore, nanoid } from '@reduxjs/toolkit';
|
|
27
|
+
import { Provider } from 'react-redux';
|
|
28
|
+
// As a basic setup, import your same slice reducers
|
|
29
|
+
import { EurekaFormsReducer } from './store';
|
|
30
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
31
|
+
import { IdFormContext } from '../App/App';
|
|
32
|
+
import { StoreContext } from '../hooks';
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
34
|
+
export function renderWithProviders(ui, _a) {
|
|
35
|
+
if (_a === void 0) { _a = {}; }
|
|
36
|
+
var
|
|
37
|
+
// Automatically create a store instance if no store was passed in
|
|
38
|
+
_b = _a.store,
|
|
39
|
+
// Automatically create a store instance if no store was passed in
|
|
40
|
+
store = _b === void 0 ? configureStore({
|
|
41
|
+
reducer: EurekaFormsReducer,
|
|
42
|
+
}) : _b, renderOptions = __rest(_a, ["store"]);
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
44
|
+
function Wrapper(_a) {
|
|
45
|
+
var children = _a.children;
|
|
46
|
+
return _jsx(Provider, __assign({ store: store }, { children: children }));
|
|
47
|
+
}
|
|
48
|
+
// Return an object with the store and all of RTL's query functions
|
|
49
|
+
return __assign({ store: store }, render(ui, __assign({ wrapper: Wrapper }, renderOptions)));
|
|
50
|
+
}
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
52
|
+
export function renderHookWithProviders(callback, _a) {
|
|
53
|
+
if (_a === void 0) { _a = {}; }
|
|
54
|
+
var _b = _a.store, store = _b === void 0 ? configureStore({
|
|
55
|
+
reducer: EurekaFormsReducer,
|
|
56
|
+
}) : _b, renderHookOptions = __rest(_a, ["store"]);
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
58
|
+
function Wrapper(_a) {
|
|
59
|
+
var children = _a.children;
|
|
60
|
+
var idForm = React.useState(nanoid(6))[0];
|
|
61
|
+
return (_jsx(IdFormContext.Provider, __assign({ value: idForm }, { children: _jsx(Provider, __assign({ store: store, context: StoreContext }, { children: children })) })));
|
|
62
|
+
}
|
|
63
|
+
// Return an object with the store and all of RTL's query functions
|
|
64
|
+
return __assign({ store: store }, renderHook(callback, __assign({ wrapper: Wrapper }, renderHookOptions)));
|
|
65
|
+
}
|
package/dist/Utils/store.d.ts
CHANGED
|
@@ -9,8 +9,10 @@ export interface RootState {
|
|
|
9
9
|
}
|
|
10
10
|
export declare const defaultRootState: RootState;
|
|
11
11
|
export type EurekaFormsState = Record<string, RootState>;
|
|
12
|
+
export declare function EurekaFormsReducer(state: EurekaFormsState | undefined, action: AnyAction): EurekaFormsState;
|
|
12
13
|
export declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<EurekaFormsState, AnyAction, [import("@reduxjs/toolkit").ThunkMiddleware<EurekaFormsState, AnyAction, undefined>]>;
|
|
13
14
|
export type AppDispatch = typeof store.dispatch;
|
|
15
|
+
export type AppStore = typeof store;
|
|
14
16
|
export declare const getAppState: import("@reduxjs/toolkit").AsyncThunk<RootState, {
|
|
15
17
|
idForm: string;
|
|
16
18
|
}, {
|
package/dist/Utils/store.js
CHANGED
|
@@ -59,7 +59,7 @@ var FormReducer = combineReducers({
|
|
|
59
59
|
site: SiteSlice.reducer,
|
|
60
60
|
widthStats: WidthStatsSlice.reducer,
|
|
61
61
|
});
|
|
62
|
-
function EurekaFormsReducer(state, action) {
|
|
62
|
+
export function EurekaFormsReducer(state, action) {
|
|
63
63
|
var _a, _b;
|
|
64
64
|
var _c;
|
|
65
65
|
if (state === void 0) { state = {}; }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arquimedes.co/eureka-forms",
|
|
3
3
|
"repository": "git://github.com/Arquimede5/Eureka-Forms.git",
|
|
4
|
-
"version":"2.0.
|
|
4
|
+
"version":"2.0.25-test",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "react-scripts start",
|
|
7
7
|
"build": "react-scripts build",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@testing-library/dom": "^9.3.3",
|
|
71
71
|
"@testing-library/jest-dom": "^6.1.5",
|
|
72
72
|
"@testing-library/react": "^12.1.5",
|
|
73
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
73
74
|
"@testing-library/user-event": "^14.5.1",
|
|
74
75
|
"@types/draft-js": "^0.11.16",
|
|
75
76
|
"@types/jest": "^29.5.10",
|
|
@@ -87,9 +88,11 @@
|
|
|
87
88
|
"eslint-plugin-css-modules": "^2.12.0",
|
|
88
89
|
"eslint-plugin-prettier": "^5.0.1",
|
|
89
90
|
"eslint-plugin-storybook": "^0.6.15",
|
|
91
|
+
"identity-obj-proxy": "^3.0.0",
|
|
90
92
|
"jest": "^29.7.0",
|
|
91
93
|
"jest-environment-jsdom": "^29.7.0",
|
|
92
94
|
"jest-junit": "^16.0.0",
|
|
95
|
+
"jest-mock-axios": "^4.7.3",
|
|
93
96
|
"prettier": "^3.1.0",
|
|
94
97
|
"react-docgen-typescript": "^2.2.2",
|
|
95
98
|
"react-refresh": "^0.11.0",
|
|
@@ -109,5 +112,13 @@
|
|
|
109
112
|
"files": [
|
|
110
113
|
"/dist"
|
|
111
114
|
],
|
|
115
|
+
"jest": {
|
|
116
|
+
"transformIgnorePatterns": [
|
|
117
|
+
"node_modules/(?!axios)"
|
|
118
|
+
],
|
|
119
|
+
"moduleNameMapper": {
|
|
120
|
+
"\\.(scss|sass|css)$": "identity-obj-proxy"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
112
123
|
"proxy": "https://api.forms.eureka-test.click"
|
|
113
124
|
}
|
|
File without changes
|
|
File without changes
|