@tsed/react-formio 1.14.1 → 2.0.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 (174) hide show
  1. package/coverage.json +4 -4
  2. package/dist/index.d.ts +3 -2
  3. package/dist/index.js +1277 -3684
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.modern.js +956 -2767
  6. package/dist/index.modern.js.map +1 -1
  7. package/package.json +4 -5
  8. package/readme.md +9 -57
  9. package/src/components/input-tags/inputTags.component.tsx +1 -1
  10. package/src/components/select/select.component.tsx +1 -1
  11. package/src/components/table/filters/sliderColumnFilter.component.tsx +2 -2
  12. package/src/index.ts +3 -2
  13. package/dist/stores/action/action.actions.d.ts +0 -9
  14. package/dist/stores/action/action.actions.spec.d.ts +0 -1
  15. package/dist/stores/action/action.constant.d.ts +0 -1
  16. package/dist/stores/action/action.reducers.d.ts +0 -7
  17. package/dist/stores/action/action.reducers.spec.d.ts +0 -1
  18. package/dist/stores/action/action.selectors.d.ts +0 -2
  19. package/dist/stores/action/action.selectors.spec.d.ts +0 -1
  20. package/dist/stores/action/index.d.ts +0 -4
  21. package/dist/stores/action-info/action-info.actions.d.ts +0 -5
  22. package/dist/stores/action-info/action-info.actions.spec.d.ts +0 -1
  23. package/dist/stores/action-info/action-info.constant.d.ts +0 -1
  24. package/dist/stores/action-info/action-info.reducers.d.ts +0 -7
  25. package/dist/stores/action-info/action-info.reducers.spec.d.ts +0 -1
  26. package/dist/stores/action-info/action-info.selectors.d.ts +0 -2
  27. package/dist/stores/action-info/action-info.selectors.spec.d.ts +0 -1
  28. package/dist/stores/action-info/index.d.ts +0 -4
  29. package/dist/stores/actions/actions.actions.d.ts +0 -5
  30. package/dist/stores/actions/actions.actions.spec.d.ts +0 -1
  31. package/dist/stores/actions/actions.constant.d.ts +0 -1
  32. package/dist/stores/actions/actions.reducers.d.ts +0 -8
  33. package/dist/stores/actions/actions.reducers.spec.d.ts +0 -1
  34. package/dist/stores/actions/actions.selectors.d.ts +0 -2
  35. package/dist/stores/actions/actions.selectors.spec.d.ts +0 -1
  36. package/dist/stores/actions/index.d.ts +0 -4
  37. package/dist/stores/auth/auth.actions.d.ts +0 -9
  38. package/dist/stores/auth/auth.constant.d.ts +0 -1
  39. package/dist/stores/auth/auth.reducers.d.ts +0 -16
  40. package/dist/stores/auth/auth.reducers.spec.d.ts +0 -1
  41. package/dist/stores/auth/auth.selectors.d.ts +0 -6
  42. package/dist/stores/auth/auth.selectors.spec.d.ts +0 -1
  43. package/dist/stores/auth/auth.utils.d.ts +0 -6
  44. package/dist/stores/auth/auth.utils.spec.d.ts +0 -1
  45. package/dist/stores/auth/getAccess.action.d.ts +0 -1
  46. package/dist/stores/auth/getAccess.action.spec.d.ts +0 -1
  47. package/dist/stores/auth/getProjectAccess.action.d.ts +0 -1
  48. package/dist/stores/auth/index.d.ts +0 -10
  49. package/dist/stores/auth/initAuth.action.d.ts +0 -1
  50. package/dist/stores/auth/initAuth.action.spec.d.ts +0 -1
  51. package/dist/stores/auth/logout.action.d.ts +0 -1
  52. package/dist/stores/auth/logout.action.spec.d.ts +0 -1
  53. package/dist/stores/auth/setUser.action.d.ts +0 -1
  54. package/dist/stores/auth/setUser.action.spec.d.ts +0 -1
  55. package/dist/stores/form/form.actions.d.ts +0 -10
  56. package/dist/stores/form/form.actions.spec.d.ts +0 -1
  57. package/dist/stores/form/form.reducers.d.ts +0 -9
  58. package/dist/stores/form/form.reducers.spec.d.ts +0 -1
  59. package/dist/stores/form/form.selectors.d.ts +0 -2
  60. package/dist/stores/form/form.selectors.spec.d.ts +0 -1
  61. package/dist/stores/form/index.d.ts +0 -3
  62. package/dist/stores/forms/forms.actions.d.ts +0 -9
  63. package/dist/stores/forms/forms.actions.spec.d.ts +0 -1
  64. package/dist/stores/forms/forms.reducers.d.ts +0 -16
  65. package/dist/stores/forms/forms.reducers.spec.d.ts +0 -1
  66. package/dist/stores/forms/forms.selectors.d.ts +0 -10
  67. package/dist/stores/forms/forms.selectors.spec.d.ts +0 -1
  68. package/dist/stores/forms/index.d.ts +0 -3
  69. package/dist/stores/index.d.ts +0 -10
  70. package/dist/stores/index.spec.d.ts +0 -1
  71. package/dist/stores/root/index.d.ts +0 -1
  72. package/dist/stores/root/root.selectors.d.ts +0 -5
  73. package/dist/stores/root/root.selectors.spec.d.ts +0 -1
  74. package/dist/stores/submission/index.d.ts +0 -3
  75. package/dist/stores/submission/submission.actions.d.ts +0 -10
  76. package/dist/stores/submission/submission.actions.spec.d.ts +0 -1
  77. package/dist/stores/submission/submission.reducers.d.ts +0 -11
  78. package/dist/stores/submission/submission.reducers.spec.d.ts +0 -1
  79. package/dist/stores/submission/submission.selectors.d.ts +0 -2
  80. package/dist/stores/submission/submission.selectors.spec.d.ts +0 -1
  81. package/dist/stores/submissions/index.d.ts +0 -3
  82. package/dist/stores/submissions/submissions.actions.d.ts +0 -6
  83. package/dist/stores/submissions/submissions.actions.spec.d.ts +0 -1
  84. package/dist/stores/submissions/submissions.reducers.d.ts +0 -17
  85. package/dist/stores/submissions/submissions.reducers.spec.d.ts +0 -1
  86. package/dist/stores/submissions/submissions.selectors.d.ts +0 -9
  87. package/dist/stores/submissions/submissions.selectors.spec.d.ts +0 -1
  88. package/dist/utils/clean.d.ts +0 -1
  89. package/dist/utils/clean.test.d.ts +0 -1
  90. package/dist/utils/mapRequestParams.d.ts +0 -9
  91. package/dist/utils/mapRequestParams.test.d.ts +0 -1
  92. package/dist/utils/url.d.ts +0 -3
  93. package/dist/utils/url.test.d.ts +0 -1
  94. package/src/stores/action/action.actions.spec.ts +0 -114
  95. package/src/stores/action/action.actions.ts +0 -82
  96. package/src/stores/action/action.constant.ts +0 -1
  97. package/src/stores/action/action.reducers.spec.ts +0 -91
  98. package/src/stores/action/action.reducers.ts +0 -54
  99. package/src/stores/action/action.selectors.spec.ts +0 -19
  100. package/src/stores/action/action.selectors.ts +0 -6
  101. package/src/stores/action/index.ts +0 -4
  102. package/src/stores/action-info/action-info.actions.spec.ts +0 -46
  103. package/src/stores/action-info/action-info.actions.ts +0 -32
  104. package/src/stores/action-info/action-info.constant.ts +0 -1
  105. package/src/stores/action-info/action-info.reducers.spec.ts +0 -60
  106. package/src/stores/action-info/action-info.reducers.ts +0 -44
  107. package/src/stores/action-info/action-info.selectors.spec.ts +0 -19
  108. package/src/stores/action-info/action-info.selectors.ts +0 -7
  109. package/src/stores/action-info/index.ts +0 -4
  110. package/src/stores/actions/actions.actions.spec.ts +0 -62
  111. package/src/stores/actions/actions.actions.ts +0 -34
  112. package/src/stores/actions/actions.constant.ts +0 -1
  113. package/src/stores/actions/actions.reducers.spec.ts +0 -62
  114. package/src/stores/actions/actions.reducers.ts +0 -48
  115. package/src/stores/actions/actions.selectors.spec.ts +0 -34
  116. package/src/stores/actions/actions.selectors.ts +0 -7
  117. package/src/stores/actions/index.ts +0 -4
  118. package/src/stores/auth/auth.actions.ts +0 -13
  119. package/src/stores/auth/auth.constant.ts +0 -1
  120. package/src/stores/auth/auth.reducers.spec.ts +0 -376
  121. package/src/stores/auth/auth.reducers.ts +0 -151
  122. package/src/stores/auth/auth.selectors.spec.ts +0 -47
  123. package/src/stores/auth/auth.selectors.ts +0 -14
  124. package/src/stores/auth/auth.utils.spec.ts +0 -29
  125. package/src/stores/auth/auth.utils.tsx +0 -37
  126. package/src/stores/auth/getAccess.action.spec.ts +0 -257
  127. package/src/stores/auth/getAccess.action.ts +0 -57
  128. package/src/stores/auth/getProjectAccess.action.ts +0 -25
  129. package/src/stores/auth/index.ts +0 -10
  130. package/src/stores/auth/initAuth.action.spec.ts +0 -56
  131. package/src/stores/auth/initAuth.action.ts +0 -29
  132. package/src/stores/auth/logout.action.spec.ts +0 -25
  133. package/src/stores/auth/logout.action.ts +0 -9
  134. package/src/stores/auth/setUser.action.spec.ts +0 -25
  135. package/src/stores/auth/setUser.action.ts +0 -9
  136. package/src/stores/form/form.actions.spec.ts +0 -203
  137. package/src/stores/form/form.actions.ts +0 -84
  138. package/src/stores/form/form.reducers.spec.ts +0 -78
  139. package/src/stores/form/form.reducers.ts +0 -59
  140. package/src/stores/form/form.selectors.spec.ts +0 -19
  141. package/src/stores/form/form.selectors.ts +0 -5
  142. package/src/stores/form/index.ts +0 -3
  143. package/src/stores/forms/forms.actions.spec.ts +0 -91
  144. package/src/stores/forms/forms.actions.ts +0 -44
  145. package/src/stores/forms/forms.reducers.spec.ts +0 -97
  146. package/src/stores/forms/forms.reducers.ts +0 -77
  147. package/src/stores/forms/forms.selectors.spec.ts +0 -39
  148. package/src/stores/forms/forms.selectors.ts +0 -6
  149. package/src/stores/forms/index.ts +0 -3
  150. package/src/stores/index.spec.ts +0 -125
  151. package/src/stores/index.ts +0 -33
  152. package/src/stores/root/index.ts +0 -1
  153. package/src/stores/root/root.selectors.spec.ts +0 -94
  154. package/src/stores/root/root.selectors.ts +0 -23
  155. package/src/stores/submission/index.ts +0 -3
  156. package/src/stores/submission/submission.actions.spec.ts +0 -214
  157. package/src/stores/submission/submission.actions.ts +0 -81
  158. package/src/stores/submission/submission.reducers.spec.ts +0 -96
  159. package/src/stores/submission/submission.reducers.ts +0 -70
  160. package/src/stores/submission/submission.selectors.spec.ts +0 -19
  161. package/src/stores/submission/submission.selectors.ts +0 -5
  162. package/src/stores/submissions/index.ts +0 -3
  163. package/src/stores/submissions/submissions.actions.spec.ts +0 -99
  164. package/src/stores/submissions/submissions.actions.ts +0 -38
  165. package/src/stores/submissions/submissions.reducers.spec.ts +0 -98
  166. package/src/stores/submissions/submissions.reducers.ts +0 -78
  167. package/src/stores/submissions/submissions.selectors.spec.ts +0 -39
  168. package/src/stores/submissions/submissions.selectors.ts +0 -6
  169. package/src/utils/clean.test.ts +0 -7
  170. package/src/utils/clean.ts +0 -12
  171. package/src/utils/mapRequestParams.test.ts +0 -81
  172. package/src/utils/mapRequestParams.ts +0 -36
  173. package/src/utils/url.test.ts +0 -31
  174. package/src/utils/url.ts +0 -23
@@ -1,34 +0,0 @@
1
- import { createAction } from "@tsed/redux-utils";
2
- import { Formio } from "formiojs";
3
- import noop from "lodash/noop";
4
-
5
- import { getFormUrl } from "../../utils/url";
6
- import { ACTIONS } from "./actions.constant";
7
-
8
- export const resetActions = createAction();
9
- export const requestActions = createAction();
10
- export const receiveActions = createAction<{
11
- actions: any[];
12
- availableActions: any[];
13
- }>();
14
- export const failActions = createAction<{ error: Error }>();
15
-
16
- export const getActions =
17
- (id: string, done = noop) =>
18
- async (dispatch: any) => {
19
- dispatch(resetActions(ACTIONS));
20
- dispatch(requestActions(ACTIONS));
21
-
22
- const url = getFormUrl(id);
23
- const formio = new Formio(url);
24
-
25
- try {
26
- const [actions, availableActions] = await Promise.all([formio.loadActions({ params: {} }), formio.availableActions()]);
27
-
28
- dispatch(receiveActions(ACTIONS, { actions, availableActions }));
29
- done(null, actions, availableActions);
30
- } catch (error) {
31
- dispatch(failActions(ACTIONS, { error }));
32
- done(error);
33
- }
34
- };
@@ -1 +0,0 @@
1
- export const ACTIONS = "actions";
@@ -1,62 +0,0 @@
1
- import { failActions, receiveActions, requestActions, resetActions } from "./actions.actions";
2
- import { ACTIONS } from "./actions.constant";
3
- import { actionsReducer } from "./actions.reducers";
4
-
5
- describe("Actions reducers", () => {
6
- it("should return state (resetActions)", () => {
7
- const reducer = actionsReducer;
8
- const state: any = {};
9
- const payload = {};
10
-
11
- expect(reducer.$emit(resetActions, state, payload)).toEqual({
12
- name: ACTIONS,
13
- data: [],
14
- availableActions: [],
15
- error: null,
16
- isActive: false
17
- });
18
- });
19
- it("should return state (requestActions)", () => {
20
- const reducer = actionsReducer;
21
- const state: any = {};
22
- const payload = {};
23
-
24
- expect(reducer.$emit(requestActions, state, payload)).toEqual({
25
- name: ACTIONS,
26
- data: [],
27
- availableActions: [],
28
- error: null,
29
- isActive: true
30
- });
31
- });
32
-
33
- it("should return state (receiveActions)", () => {
34
- const reducer = actionsReducer;
35
- const state: any = {};
36
- const payload = {
37
- actions: [{ _id: "id" }]
38
- };
39
-
40
- expect(reducer.$emit(receiveActions, state, payload)).toEqual({
41
- name: ACTIONS,
42
- error: null,
43
- data: [{ _id: "id" }],
44
- isActive: false
45
- });
46
- });
47
-
48
- it("should return state (failActions)", () => {
49
- const reducer = actionsReducer;
50
- const state: any = {};
51
- const payload = {
52
- error: new Error("message")
53
- };
54
-
55
- expect(reducer.$emit(failActions, state, payload)).toEqual({
56
- name: ACTIONS,
57
- data: [],
58
- error: payload.error,
59
- isActive: false
60
- });
61
- });
62
- });
@@ -1,48 +0,0 @@
1
- import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
2
-
3
- import { ActionInfoSchema, ActionSchema } from "../../interfaces";
4
- import { failActions, receiveActions, requestActions, resetActions } from "./actions.actions";
5
- import { ACTIONS } from "./actions.constant";
6
-
7
- export interface ActionsState {
8
- error: null | Error;
9
- data: ActionSchema[];
10
- availableActions: ActionInfoSchema[];
11
- isActive: boolean;
12
- }
13
-
14
- const createInitialState: InitialStateCreator<ActionsState> = () => ({
15
- error: null,
16
- data: [],
17
- availableActions: [],
18
- isActive: false
19
- });
20
-
21
- export const actionsReducer = createReducer<ActionsState>(
22
- {
23
- [resetActions.toString()]: (_, _2, reset) => {
24
- return reset();
25
- },
26
- [requestActions.toString()]: (state) => ({
27
- ...state,
28
- error: null,
29
- data: [],
30
- availableActions: [],
31
- isActive: true
32
- }),
33
- [receiveActions.toString()]: (state, { actions, availableActions }) => ({
34
- ...state,
35
- error: null,
36
- data: actions,
37
- availableActions,
38
- isActive: false
39
- }),
40
- [failActions.toString()]: (state, { error }) => ({
41
- ...state,
42
- error,
43
- data: [],
44
- isActive: false
45
- })
46
- },
47
- createInitialState
48
- )(ACTIONS);
@@ -1,34 +0,0 @@
1
- import { selectActions, selectAvailableActions } from "./actions.selectors";
2
-
3
- describe("actions Selectors", () => {
4
- describe("selectActions()", () => {
5
- it("should return actions", () => {
6
- expect(
7
- selectActions({
8
- actions: {
9
- data: {
10
- id: "id"
11
- },
12
- availableActions: {}
13
- }
14
- })
15
- ).toEqual({
16
- id: "id"
17
- });
18
- });
19
- });
20
- describe("selectAvailableActions()", () => {
21
- it("should return available actions", () => {
22
- expect(
23
- selectAvailableActions({
24
- actions: {
25
- data: {
26
- id: "id"
27
- },
28
- availableActions: []
29
- }
30
- })
31
- ).toEqual([]);
32
- });
33
- });
34
- });
@@ -1,7 +0,0 @@
1
- import { selectRoot } from "../root";
2
- import { ACTIONS } from "./actions.constant";
3
- import { ActionsState } from "./actions.reducers";
4
-
5
- export const selectActions = (state: Record<string, any>) => selectRoot<ActionsState>(ACTIONS, state).data;
6
-
7
- export const selectAvailableActions = (state: Record<string, any>) => selectRoot<ActionsState>(ACTIONS, state).availableActions;
@@ -1,4 +0,0 @@
1
- export * from "./actions.actions";
2
- export * from "./actions.constant";
3
- export * from "./actions.reducers";
4
- export * from "./actions.selectors";
@@ -1,13 +0,0 @@
1
- import { createAction } from "@tsed/redux-utils";
2
-
3
- import { FormSchema, RoleSchema, Submission } from "../../interfaces";
4
-
5
- export const requestUser = createAction();
6
- export const receiveUser = createAction<{ user: Submission }>();
7
- export const failUser = createAction<{ error: Error }>();
8
- export const logoutUser = createAction();
9
- export const submissionAccessUser = createAction<{ submissionAccess: any }>();
10
- export const formAccessUser = createAction<{ formAccess: any }>();
11
- export const projectAccessUser = createAction<{ projectAccess: any }>();
12
- export const userRoles = createAction<{ roles: Record<string, RoleSchema> }>();
13
- export const userForms = createAction<{ forms: Record<string, FormSchema> }>();
@@ -1 +0,0 @@
1
- export const AUTH = "auth";
@@ -1,376 +0,0 @@
1
- import {
2
- failUser,
3
- formAccessUser,
4
- logoutUser,
5
- projectAccessUser,
6
- receiveUser,
7
- requestUser,
8
- submissionAccessUser,
9
- userForms,
10
- userRoles
11
- } from "./auth.actions";
12
- import { AUTH } from "./auth.constant";
13
- import { authReducer } from "./auth.reducers";
14
-
15
- describe("Auth reducer", () => {
16
- it("should return state (requestUser)", () => {
17
- const payload = {};
18
-
19
- expect(
20
- authReducer(undefined, {
21
- type: requestUser.toString(),
22
- payload,
23
- name: AUTH
24
- })
25
- ).toEqual({
26
- authenticated: false,
27
- error: null,
28
- formAccess: {},
29
- forms: {},
30
- init: true,
31
- is: {},
32
- isActive: true,
33
- name: "auth",
34
- projectAccess: {},
35
- roles: {},
36
- submissionAccess: false,
37
- user: null
38
- });
39
- });
40
- it("should return state (receiveUser)", () => {
41
- const payload = {
42
- user: {
43
- _id: "id"
44
- }
45
- };
46
-
47
- expect(
48
- authReducer(undefined, {
49
- type: receiveUser.toString(),
50
- payload,
51
- name: AUTH
52
- })
53
- ).toEqual({
54
- authenticated: true,
55
- error: null,
56
- formAccess: {},
57
- forms: {},
58
- init: false,
59
- is: {},
60
- isActive: false,
61
- name: "auth",
62
- projectAccess: {},
63
- roles: {},
64
- submissionAccess: {},
65
- user: {
66
- _id: "id"
67
- }
68
- });
69
- });
70
- it("should return state (failUser)", () => {
71
- const payload = {
72
- error: {}
73
- };
74
-
75
- expect(
76
- authReducer(undefined, {
77
- type: failUser.toString(),
78
- payload,
79
- name: AUTH
80
- })
81
- ).toEqual({
82
- authenticated: false,
83
- error: {},
84
- formAccess: {},
85
- forms: {},
86
- init: false,
87
- is: {},
88
- isActive: false,
89
- name: "auth",
90
- projectAccess: {},
91
- roles: {},
92
- submissionAccess: {},
93
- user: null
94
- });
95
- });
96
- it("should return state (logoutUser)", () => {
97
- const payload = {};
98
- const state: any = {
99
- authenticated: true,
100
- error: null,
101
- formAccess: {},
102
- forms: {},
103
- init: false,
104
- is: {},
105
- isActive: false,
106
- name: "auth",
107
- projectAccess: {},
108
- roles: {},
109
- submissionAccess: {},
110
- user: {
111
- _id: "id"
112
- }
113
- };
114
-
115
- expect(
116
- authReducer(state, {
117
- type: logoutUser.toString(),
118
- payload,
119
- name: AUTH
120
- })
121
- ).toEqual({
122
- authenticated: false,
123
- error: null,
124
- formAccess: {},
125
- forms: {},
126
- init: false,
127
- is: {},
128
- isActive: false,
129
- name: "auth",
130
- projectAccess: {},
131
- roles: {},
132
- submissionAccess: {},
133
- user: null
134
- });
135
- });
136
- it("should return state (submissionAccessUser)", () => {
137
- const payload = {
138
- submissionAccess: {
139
- sub: {}
140
- }
141
- };
142
- const state: any = {
143
- authenticated: true,
144
- error: null,
145
- formAccess: {},
146
- forms: {},
147
- init: false,
148
- is: {},
149
- isActive: false,
150
- name: "auth",
151
- projectAccess: {},
152
- roles: {},
153
- submissionAccess: {},
154
- user: {
155
- _id: "id"
156
- }
157
- };
158
-
159
- expect(
160
- authReducer(state, {
161
- type: submissionAccessUser.toString(),
162
- payload,
163
- name: AUTH
164
- })
165
- ).toEqual({
166
- authenticated: true,
167
- error: null,
168
- formAccess: {},
169
- forms: {},
170
- init: false,
171
- is: {},
172
- isActive: false,
173
- name: "auth",
174
- projectAccess: {},
175
- roles: {},
176
- submissionAccess: {
177
- sub: {}
178
- },
179
- user: {
180
- _id: "id"
181
- }
182
- });
183
- });
184
- it("should return state (formAccessUser)", () => {
185
- const payload = {
186
- formAccess: {
187
- sub: {}
188
- }
189
- };
190
- const state: any = {
191
- authenticated: true,
192
- error: null,
193
- formAccess: {},
194
- forms: {},
195
- init: false,
196
- is: {},
197
- isActive: false,
198
- name: "auth",
199
- projectAccess: {},
200
- roles: {},
201
- submissionAccess: {},
202
- user: {
203
- _id: "id"
204
- }
205
- };
206
-
207
- expect(
208
- authReducer(state, {
209
- type: formAccessUser.toString(),
210
- payload,
211
- name: AUTH
212
- })
213
- ).toEqual({
214
- authenticated: true,
215
- error: null,
216
- formAccess: {
217
- sub: {}
218
- },
219
- forms: {},
220
- init: false,
221
- is: {},
222
- isActive: false,
223
- name: "auth",
224
- projectAccess: {},
225
- roles: {},
226
- submissionAccess: {},
227
- user: {
228
- _id: "id"
229
- }
230
- });
231
- });
232
- it("should return state (userForms)", () => {
233
- const payload = {
234
- forms: {
235
- sub: {}
236
- }
237
- };
238
- const state: any = {
239
- authenticated: true,
240
- error: null,
241
- formAccess: {},
242
- forms: {},
243
- init: false,
244
- is: {},
245
- isActive: false,
246
- name: "auth",
247
- projectAccess: {},
248
- roles: {},
249
- submissionAccess: {},
250
- user: {
251
- _id: "id"
252
- }
253
- };
254
-
255
- expect(
256
- authReducer(state, {
257
- type: userForms.toString(),
258
- payload,
259
- name: AUTH
260
- })
261
- ).toEqual({
262
- authenticated: true,
263
- error: null,
264
- formAccess: {},
265
- forms: {
266
- sub: {}
267
- },
268
- init: false,
269
- is: {},
270
- isActive: false,
271
- name: "auth",
272
- projectAccess: {},
273
- roles: {},
274
- submissionAccess: {},
275
- user: {
276
- _id: "id"
277
- }
278
- });
279
- });
280
- it("should return state (projectAccessUser)", () => {
281
- const payload = {
282
- projectAccess: {
283
- sub: {}
284
- }
285
- };
286
- const state: any = {
287
- authenticated: true,
288
- error: null,
289
- formAccess: {},
290
- forms: {},
291
- init: false,
292
- is: {},
293
- isActive: false,
294
- name: "auth",
295
- projectAccess: {},
296
- roles: {},
297
- submissionAccess: {},
298
- user: {
299
- _id: "id"
300
- }
301
- };
302
-
303
- expect(
304
- authReducer(state, {
305
- type: projectAccessUser.toString(),
306
- payload,
307
- name: AUTH
308
- })
309
- ).toEqual({
310
- authenticated: true,
311
- error: null,
312
- formAccess: {},
313
- forms: {},
314
- init: false,
315
- is: {},
316
- isActive: false,
317
- name: "auth",
318
- projectAccess: {
319
- sub: {}
320
- },
321
- roles: {},
322
- submissionAccess: {},
323
- user: {
324
- _id: "id"
325
- }
326
- });
327
- });
328
- it("should return state (userRoles)", () => {
329
- const payload = {
330
- roles: {
331
- sub: {}
332
- }
333
- };
334
- const state: any = {
335
- authenticated: true,
336
- error: null,
337
- formAccess: {},
338
- forms: {},
339
- init: false,
340
- is: {},
341
- isActive: false,
342
- name: "auth",
343
- projectAccess: {},
344
- roles: {},
345
- submissionAccess: {},
346
- user: {
347
- _id: "id"
348
- }
349
- };
350
-
351
- expect(
352
- authReducer(state, {
353
- type: userRoles.toString(),
354
- payload,
355
- name: AUTH
356
- })
357
- ).toEqual({
358
- authenticated: true,
359
- error: null,
360
- formAccess: {},
361
- forms: {},
362
- init: false,
363
- is: {},
364
- isActive: false,
365
- name: "auth",
366
- projectAccess: {},
367
- roles: {
368
- sub: {}
369
- },
370
- submissionAccess: {},
371
- user: {
372
- _id: "id"
373
- }
374
- });
375
- });
376
- });