@appsemble/utils 0.20.45 → 0.21.1
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/README.md +3 -3
- package/api/components/schemas/ObjectRemapperDefinition.js +6 -504
- package/api/components/schemas/RequestActionDefinition.js +1 -1
- package/api/components/schemas/ScimPatchOp.d.ts +2 -0
- package/api/components/schemas/ScimPatchOp.js +47 -0
- package/api/components/schemas/ScimSecret.d.ts +2 -0
- package/api/components/schemas/ScimSecret.js +16 -0
- package/api/components/schemas/ScimUser.d.ts +2 -0
- package/api/components/schemas/ScimUser.js +60 -0
- package/api/components/schemas/index.d.ts +3 -0
- package/api/components/schemas/index.js +3 -0
- package/api/components/securitySchemes/index.d.ts +1 -0
- package/api/components/securitySchemes/index.js +1 -0
- package/api/components/securitySchemes/scim.d.ts +2 -0
- package/api/components/securitySchemes/scim.js +6 -0
- package/api/index.test.js +1 -1
- package/api/paths/appScimEndpoints.d.ts +2 -0
- package/api/paths/appScimEndpoints.js +260 -0
- package/api/paths/appScimSecrets.d.ts +2 -0
- package/api/paths/appScimSecrets.js +45 -0
- package/api/paths/index.js +4 -0
- package/appMessages.test.js +1 -1
- package/convertToCsv.js +1 -1
- package/iterApp.test.js +44 -48
- package/jsonschema.test.js +8 -8
- package/normalize.js +2 -2
- package/package.json +4 -4
- package/pem.js +3 -3
- package/reference-schemas/remappers/arrays.d.ts +2 -0
- package/reference-schemas/remappers/arrays.js +334 -0
- package/reference-schemas/remappers/conditionals.d.ts +2 -0
- package/reference-schemas/remappers/conditionals.js +93 -0
- package/reference-schemas/remappers/data.d.ts +2 -0
- package/reference-schemas/remappers/data.js +321 -0
- package/reference-schemas/remappers/dates.d.ts +2 -0
- package/reference-schemas/remappers/dates.js +38 -0
- package/reference-schemas/remappers/history.d.ts +2 -0
- package/reference-schemas/remappers/history.js +246 -0
- package/reference-schemas/remappers/index.d.ts +9 -0
- package/reference-schemas/remappers/index.js +10 -0
- package/reference-schemas/remappers/objects.d.ts +2 -0
- package/reference-schemas/remappers/objects.js +157 -0
- package/reference-schemas/remappers/randoms.d.ts +2 -0
- package/reference-schemas/remappers/randoms.js +35 -0
- package/reference-schemas/remappers/strings.d.ts +2 -0
- package/reference-schemas/remappers/strings.js +81 -0
- package/reference-schemas/remappers/unsorted.d.ts +2 -0
- package/reference-schemas/remappers/unsorted.js +71 -0
- package/remap.js +1 -1
- package/remap.test.js +8 -9
- package/string.js +2 -2
- package/vitest.config.d.ts +2 -0
|
@@ -89,6 +89,9 @@ export * from './SecurityDefaultDefinition.js';
|
|
|
89
89
|
export * from './SecurityDefinition.js';
|
|
90
90
|
export * from './SecurityRoleDefinition.js';
|
|
91
91
|
export * from './ShareActionDefinition.js';
|
|
92
|
+
export * from './ScimPatchOp.js';
|
|
93
|
+
export * from './ScimSecret.js';
|
|
94
|
+
export * from './ScimUser.js';
|
|
92
95
|
export * from './SSLSecret.js';
|
|
93
96
|
export * from './SSOConfiguration.js';
|
|
94
97
|
export * from './StaticActionDefinition.js';
|
|
@@ -89,6 +89,9 @@ export * from './SecurityDefaultDefinition.js';
|
|
|
89
89
|
export * from './SecurityDefinition.js';
|
|
90
90
|
export * from './SecurityRoleDefinition.js';
|
|
91
91
|
export * from './ShareActionDefinition.js';
|
|
92
|
+
export * from './ScimPatchOp.js';
|
|
93
|
+
export * from './ScimSecret.js';
|
|
94
|
+
export * from './ScimUser.js';
|
|
92
95
|
export * from './SSLSecret.js';
|
|
93
96
|
export * from './SSOConfiguration.js';
|
|
94
97
|
export * from './StaticActionDefinition.js';
|
package/api/index.test.js
CHANGED
|
@@ -89,7 +89,7 @@ describe('schemas', () => {
|
|
|
89
89
|
expect(schema).not.toHaveProperty('uniqueItems');
|
|
90
90
|
if (schema.required && !schema.additionalProperties) {
|
|
91
91
|
for (const name of schema.required) {
|
|
92
|
-
// eslint-disable-next-line
|
|
92
|
+
// eslint-disable-next-line vitest/no-conditional-expect
|
|
93
93
|
expect(schema.properties).toHaveProperty(name);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
export const paths = {
|
|
2
|
+
'/api/apps/{appId}/scim/Schemas': {
|
|
3
|
+
parameters: [{ $ref: '#/components/parameters/appId' }],
|
|
4
|
+
get: {
|
|
5
|
+
tags: ['scim'],
|
|
6
|
+
security: [{ scim: [] }],
|
|
7
|
+
operationId: 'getSCIMSchemas',
|
|
8
|
+
responses: {
|
|
9
|
+
200: {
|
|
10
|
+
description: 'The SCIM Schema',
|
|
11
|
+
content: {
|
|
12
|
+
'application/scim+json': {
|
|
13
|
+
schema: {
|
|
14
|
+
$ref: '#/components/schemas/ScimUser',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
'/api/apps/{appId}/scim/Schemas/{schemaId}': {
|
|
23
|
+
parameters: [
|
|
24
|
+
{ $ref: '#/components/parameters/appId' },
|
|
25
|
+
{ name: 'schemaId', in: 'path', schema: { type: 'string' } },
|
|
26
|
+
],
|
|
27
|
+
get: {
|
|
28
|
+
tags: ['scim'],
|
|
29
|
+
security: [{ scim: [] }],
|
|
30
|
+
operationId: 'getSCIMSchema',
|
|
31
|
+
responses: {
|
|
32
|
+
200: {
|
|
33
|
+
description: 'The SCIM Schema',
|
|
34
|
+
content: {
|
|
35
|
+
'application/scim+json': {
|
|
36
|
+
schema: {
|
|
37
|
+
$ref: '#/components/schemas/ScimUser',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
'/api/apps/{appId}/scim/ResourceTypes': {
|
|
46
|
+
parameters: [{ $ref: '#/components/parameters/appId' }],
|
|
47
|
+
get: {
|
|
48
|
+
tags: ['scim'],
|
|
49
|
+
security: [{ scim: [] }],
|
|
50
|
+
operationId: 'getSCIMResourceTypes',
|
|
51
|
+
responses: {
|
|
52
|
+
200: {
|
|
53
|
+
description: 'SCIM user',
|
|
54
|
+
content: {
|
|
55
|
+
'application/scim+json': {
|
|
56
|
+
schema: {
|
|
57
|
+
// XXX
|
|
58
|
+
// $ref: '#/components/schemas/ScimUser',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
'/api/apps/{appId}/scim/ResourceTypes/{resourceTypeId}': {
|
|
67
|
+
parameters: [
|
|
68
|
+
{ $ref: '#/components/parameters/appId' },
|
|
69
|
+
{ name: 'resourceTypeId', in: 'path', schema: { type: 'string' } },
|
|
70
|
+
],
|
|
71
|
+
get: {
|
|
72
|
+
tags: ['scim'],
|
|
73
|
+
security: [{ scim: [] }],
|
|
74
|
+
operationId: 'getSCIMResourceType',
|
|
75
|
+
responses: {
|
|
76
|
+
200: {
|
|
77
|
+
description: 'SCIM user',
|
|
78
|
+
content: {
|
|
79
|
+
'application/scim+json': {
|
|
80
|
+
schema: {
|
|
81
|
+
// XXX
|
|
82
|
+
// $ref: '#/components/schemas/ScimUser',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
'/api/apps/{appId}/scim/ServiceProviderConfig': {
|
|
91
|
+
parameters: [{ $ref: '#/components/parameters/appId' }],
|
|
92
|
+
get: {
|
|
93
|
+
tags: ['scim'],
|
|
94
|
+
security: [{ scim: [] }],
|
|
95
|
+
operationId: 'getSCIMServiceProviderConfig',
|
|
96
|
+
responses: {
|
|
97
|
+
200: {
|
|
98
|
+
description: 'SCIM user',
|
|
99
|
+
content: {
|
|
100
|
+
'application/scim+json': {
|
|
101
|
+
schema: {
|
|
102
|
+
// XXX
|
|
103
|
+
// $ref: '#/components/schemas/ScimUser',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
'/api/apps/{appId}/scim/Users': {
|
|
112
|
+
parameters: [{ $ref: '#/components/parameters/appId' }],
|
|
113
|
+
post: {
|
|
114
|
+
tags: ['scim'],
|
|
115
|
+
security: [{ scim: [] }],
|
|
116
|
+
operationId: 'createSCIMUser',
|
|
117
|
+
requestBody: {
|
|
118
|
+
content: {
|
|
119
|
+
'application/json': {
|
|
120
|
+
schema: {
|
|
121
|
+
type: 'object',
|
|
122
|
+
additionalProperties: true,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
'application/scim+json': {
|
|
126
|
+
schema: {
|
|
127
|
+
type: 'object',
|
|
128
|
+
additionalProperties: true,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
responses: {
|
|
134
|
+
201: {
|
|
135
|
+
description: 'Integrated SCIM user schema',
|
|
136
|
+
content: {
|
|
137
|
+
'application/scim+json': {
|
|
138
|
+
schema: {
|
|
139
|
+
$ref: '#/components/schemas/ScimUser',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
get: {
|
|
147
|
+
tags: ['scim'],
|
|
148
|
+
security: [{ scim: [] }],
|
|
149
|
+
operationId: 'getSCIMUsers',
|
|
150
|
+
parameters: [
|
|
151
|
+
{ name: 'count', in: 'query', schema: { type: 'number' } },
|
|
152
|
+
{ name: 'startIndex', in: 'query', schema: { type: 'number' } },
|
|
153
|
+
],
|
|
154
|
+
responses: {
|
|
155
|
+
200: {
|
|
156
|
+
description: 'SCIM user',
|
|
157
|
+
content: {
|
|
158
|
+
'application/scim+json': {
|
|
159
|
+
schema: {
|
|
160
|
+
$ref: '#/components/schemas/ScimUser',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
'/api/apps/{appId}/scim/Users/{userId}': {
|
|
169
|
+
parameters: [
|
|
170
|
+
{ $ref: '#/components/parameters/appId' },
|
|
171
|
+
{
|
|
172
|
+
name: 'userId',
|
|
173
|
+
in: 'path',
|
|
174
|
+
description: 'The ID of the member to perform the operation on',
|
|
175
|
+
required: true,
|
|
176
|
+
schema: { $ref: '#/components/schemas/User/properties/id' },
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
get: {
|
|
180
|
+
tags: ['scim'],
|
|
181
|
+
security: [{ scim: [] }],
|
|
182
|
+
operationId: 'getSCIMUser',
|
|
183
|
+
responses: {
|
|
184
|
+
200: {
|
|
185
|
+
description: 'SCIM user',
|
|
186
|
+
content: {
|
|
187
|
+
'application/scim+json': {
|
|
188
|
+
schema: {
|
|
189
|
+
$ref: '#/components/schemas/ScimUser',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
delete: {
|
|
197
|
+
tags: ['scim'],
|
|
198
|
+
security: [{ scim: [] }],
|
|
199
|
+
operationId: 'deleteSCIMUser',
|
|
200
|
+
responses: {
|
|
201
|
+
204: {
|
|
202
|
+
description: 'SCIM user',
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
put: {
|
|
207
|
+
tags: ['scim'],
|
|
208
|
+
security: [{ scim: [] }],
|
|
209
|
+
operationId: 'updateSCIMUser',
|
|
210
|
+
requestBody: {
|
|
211
|
+
content: {
|
|
212
|
+
'application/json': {
|
|
213
|
+
schema: {
|
|
214
|
+
type: 'object',
|
|
215
|
+
additionalProperties: true,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
'application/scim+json': {
|
|
219
|
+
schema: {
|
|
220
|
+
type: 'object',
|
|
221
|
+
additionalProperties: true,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
responses: {
|
|
227
|
+
200: {
|
|
228
|
+
description: 'SCIM user',
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
patch: {
|
|
233
|
+
tags: ['scim'],
|
|
234
|
+
security: [{ scim: [] }],
|
|
235
|
+
operationId: 'patchSCIMUser',
|
|
236
|
+
requestBody: {
|
|
237
|
+
content: {
|
|
238
|
+
'application/json': {
|
|
239
|
+
schema: {
|
|
240
|
+
type: 'object',
|
|
241
|
+
additionalProperties: true,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
'application/scim+json': {
|
|
245
|
+
schema: {
|
|
246
|
+
type: 'object',
|
|
247
|
+
additionalProperties: true,
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
responses: {
|
|
253
|
+
200: {
|
|
254
|
+
description: 'SCIM user',
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
//# sourceMappingURL=appScimEndpoints.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const paths = {
|
|
2
|
+
'/api/apps/{appId}/secrets/scim': {
|
|
3
|
+
parameters: [{ $ref: '#/components/parameters/appId' }],
|
|
4
|
+
get: {
|
|
5
|
+
tags: ['secret'],
|
|
6
|
+
operationId: 'getAppScimSecret',
|
|
7
|
+
description: 'Get app SCIM secret configuration',
|
|
8
|
+
security: [{ studio: [] }],
|
|
9
|
+
responses: {
|
|
10
|
+
200: {
|
|
11
|
+
description: 'The app SCIM configuration',
|
|
12
|
+
content: {
|
|
13
|
+
'application/json': {
|
|
14
|
+
schema: { $ref: '#/components/schemas/ScimSecret' },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
patch: {
|
|
21
|
+
tags: ['secret'],
|
|
22
|
+
operationId: 'updateAppScimSecret',
|
|
23
|
+
description: 'Update app SCIM secret configuration',
|
|
24
|
+
requestBody: {
|
|
25
|
+
content: {
|
|
26
|
+
'application/json': {
|
|
27
|
+
schema: { $ref: '#/components/schemas/ScimSecret' },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
security: [{ studio: [] }],
|
|
32
|
+
responses: {
|
|
33
|
+
200: {
|
|
34
|
+
description: 'The app SCIM configuration',
|
|
35
|
+
content: {
|
|
36
|
+
'application/json': {
|
|
37
|
+
schema: { $ref: '#/components/schemas/ScimSecret' },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=appScimSecrets.js.map
|
package/api/paths/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import { paths as translations } from './appMessages.js';
|
|
|
3
3
|
import { paths as appOAuth2Secrets } from './appOAuth2Secrets.js';
|
|
4
4
|
import { paths as apps } from './apps.js';
|
|
5
5
|
import { paths as appSamlSecrets } from './appSamlSecrets.js';
|
|
6
|
+
import { paths as scimEndpoints } from './appScimEndpoints.js';
|
|
7
|
+
import { paths as appScimSecrets } from './appScimSecrets.js';
|
|
6
8
|
import { paths as appsembleMessages } from './appsembleMessages.js';
|
|
7
9
|
import { paths as appServiceSecrets } from './appServiceSecrets.js';
|
|
8
10
|
import { paths as appSSLSecrets } from './appSSLSecrets.js';
|
|
@@ -24,6 +26,8 @@ export const paths = {
|
|
|
24
26
|
...appOAuth2Secrets,
|
|
25
27
|
...apps,
|
|
26
28
|
...appSamlSecrets,
|
|
29
|
+
...appScimSecrets,
|
|
30
|
+
...scimEndpoints,
|
|
27
31
|
...appsembleMessages,
|
|
28
32
|
...appSSLSecrets,
|
|
29
33
|
...assets,
|
package/appMessages.test.js
CHANGED
|
@@ -396,7 +396,7 @@ describe('extractAppMessages', () => {
|
|
|
396
396
|
expect(result).toMatchObject({ app: { 'pages.tabs': 'Tabs', 'pages.tabs.tabs.0': 'Tab' } });
|
|
397
397
|
});
|
|
398
398
|
it('should append any messages returned by onBlock', () => {
|
|
399
|
-
const onBlock =
|
|
399
|
+
const onBlock = vi.fn().mockReturnValue({ foo: 'bar' });
|
|
400
400
|
const result = extractAppMessages({
|
|
401
401
|
defaultPage: '',
|
|
402
402
|
pages: [{ name: 'Page', blocks: [{ type: '', version: '' }] }],
|
package/convertToCsv.js
CHANGED
|
@@ -13,7 +13,7 @@ export function convertToCsv(body) {
|
|
|
13
13
|
const quote = '"';
|
|
14
14
|
const quoteRegex = new RegExp(quote, 'g');
|
|
15
15
|
const escape = (value) => value.includes(separator) || value.includes(lineEnd) || value.includes(quote)
|
|
16
|
-
? `${quote}${value.
|
|
16
|
+
? `${quote}${value.replaceAll(quoteRegex, `${quote}${quote}`)}${quote}`
|
|
17
17
|
: value;
|
|
18
18
|
if (body == null) {
|
|
19
19
|
throw new Error('No data');
|
package/iterApp.test.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { iterAction, iterApp, iterBlock, iterBlockList, iterPage } from './iterApp.js';
|
|
2
2
|
describe('iterAction', () => {
|
|
3
3
|
it('should call the appropriate callbacks', () => {
|
|
4
|
-
const onAction =
|
|
5
|
-
const onBlockList =
|
|
4
|
+
const onAction = vi.fn();
|
|
5
|
+
const onBlockList = vi.fn();
|
|
6
6
|
const action = {
|
|
7
7
|
type: 'dialog',
|
|
8
8
|
blocks: [{ type: 'list', version: '0.1.2' }],
|
|
@@ -13,8 +13,8 @@ describe('iterAction', () => {
|
|
|
13
13
|
expect(result).toBe(false);
|
|
14
14
|
});
|
|
15
15
|
it('should abort if the onAction callback returns true', () => {
|
|
16
|
-
const onAction =
|
|
17
|
-
const onBlockList =
|
|
16
|
+
const onAction = vi.fn().mockReturnValue(true);
|
|
17
|
+
const onBlockList = vi.fn();
|
|
18
18
|
const action = {
|
|
19
19
|
type: 'dialog',
|
|
20
20
|
blocks: [{ type: 'list', version: '0.1.2' }],
|
|
@@ -25,8 +25,8 @@ describe('iterAction', () => {
|
|
|
25
25
|
expect(result).toBe(true);
|
|
26
26
|
});
|
|
27
27
|
it('should call onAction for onSuccess', () => {
|
|
28
|
-
const onAction =
|
|
29
|
-
const onBlockList =
|
|
28
|
+
const onAction = vi.fn();
|
|
29
|
+
const onBlockList = vi.fn();
|
|
30
30
|
const action = {
|
|
31
31
|
type: 'noop',
|
|
32
32
|
onSuccess: {
|
|
@@ -40,10 +40,8 @@ describe('iterAction', () => {
|
|
|
40
40
|
expect(result).toBe(false);
|
|
41
41
|
});
|
|
42
42
|
it('should return true if onAction returns true for onSuccess', () => {
|
|
43
|
-
const onAction =
|
|
44
|
-
|
|
45
|
-
.mockImplementation((a, [prefix]) => prefix === 'onSuccess');
|
|
46
|
-
const onBlockList = import.meta.jest.fn();
|
|
43
|
+
const onAction = vi.fn().mockImplementation((a, [prefix]) => prefix === 'onSuccess');
|
|
44
|
+
const onBlockList = vi.fn();
|
|
47
45
|
const action = {
|
|
48
46
|
type: 'noop',
|
|
49
47
|
onSuccess: {
|
|
@@ -57,8 +55,8 @@ describe('iterAction', () => {
|
|
|
57
55
|
expect(result).toBe(true);
|
|
58
56
|
});
|
|
59
57
|
it('should call onAction for onError', () => {
|
|
60
|
-
const onAction =
|
|
61
|
-
const onBlockList =
|
|
58
|
+
const onAction = vi.fn();
|
|
59
|
+
const onBlockList = vi.fn();
|
|
62
60
|
const action = {
|
|
63
61
|
type: 'noop',
|
|
64
62
|
onError: {
|
|
@@ -72,10 +70,8 @@ describe('iterAction', () => {
|
|
|
72
70
|
expect(result).toBe(false);
|
|
73
71
|
});
|
|
74
72
|
it('should return true if onAction returns true for onError', () => {
|
|
75
|
-
const onAction =
|
|
76
|
-
|
|
77
|
-
.mockImplementation((a, [prefix]) => prefix === 'onError');
|
|
78
|
-
const onBlockList = import.meta.jest.fn();
|
|
73
|
+
const onAction = vi.fn().mockImplementation((a, [prefix]) => prefix === 'onError');
|
|
74
|
+
const onBlockList = vi.fn();
|
|
79
75
|
const action = {
|
|
80
76
|
type: 'noop',
|
|
81
77
|
onError: {
|
|
@@ -89,7 +85,7 @@ describe('iterAction', () => {
|
|
|
89
85
|
expect(result).toBe(true);
|
|
90
86
|
});
|
|
91
87
|
it('should call then and else for conditional actions', () => {
|
|
92
|
-
const onAction =
|
|
88
|
+
const onAction = vi.fn();
|
|
93
89
|
const action = {
|
|
94
90
|
type: 'condition',
|
|
95
91
|
if: true,
|
|
@@ -103,8 +99,8 @@ describe('iterAction', () => {
|
|
|
103
99
|
expect(result).toBe(false);
|
|
104
100
|
});
|
|
105
101
|
it('should return the return value of iterBlockList', () => {
|
|
106
|
-
const onAction =
|
|
107
|
-
const onBlockList =
|
|
102
|
+
const onAction = vi.fn();
|
|
103
|
+
const onBlockList = vi.fn().mockReturnValue(true);
|
|
108
104
|
const action = {
|
|
109
105
|
type: 'dialog',
|
|
110
106
|
blocks: [{ type: 'list', version: '0.1.2' }],
|
|
@@ -118,8 +114,8 @@ describe('iterAction', () => {
|
|
|
118
114
|
expect(result).toBe(true);
|
|
119
115
|
});
|
|
120
116
|
it('should not call iterBlockList if the action has no blocks', () => {
|
|
121
|
-
const onAction =
|
|
122
|
-
const onBlockList =
|
|
117
|
+
const onAction = vi.fn();
|
|
118
|
+
const onBlockList = vi.fn();
|
|
123
119
|
const action = {
|
|
124
120
|
type: 'log',
|
|
125
121
|
};
|
|
@@ -134,8 +130,8 @@ describe('iterAction', () => {
|
|
|
134
130
|
});
|
|
135
131
|
describe('iterBlock', () => {
|
|
136
132
|
it('should call the appropriate callbacks', () => {
|
|
137
|
-
const onAction =
|
|
138
|
-
const onBlock =
|
|
133
|
+
const onAction = vi.fn();
|
|
134
|
+
const onBlock = vi.fn();
|
|
139
135
|
const block = {
|
|
140
136
|
type: 'list',
|
|
141
137
|
version: '1.2.3',
|
|
@@ -151,8 +147,8 @@ describe('iterBlock', () => {
|
|
|
151
147
|
expect(result).toBe(false);
|
|
152
148
|
});
|
|
153
149
|
it('should abort if onBlock returns true', () => {
|
|
154
|
-
const onAction =
|
|
155
|
-
const onBlock =
|
|
150
|
+
const onAction = vi.fn();
|
|
151
|
+
const onBlock = vi.fn().mockReturnValue(true);
|
|
156
152
|
const block = {
|
|
157
153
|
type: 'list',
|
|
158
154
|
version: '1.2.3',
|
|
@@ -168,8 +164,8 @@ describe('iterBlock', () => {
|
|
|
168
164
|
expect(result).toBe(true);
|
|
169
165
|
});
|
|
170
166
|
it('should return the return value of onAction', () => {
|
|
171
|
-
const onAction =
|
|
172
|
-
const onBlock =
|
|
167
|
+
const onAction = vi.fn().mockReturnValue(true);
|
|
168
|
+
const onBlock = vi.fn();
|
|
173
169
|
const block = {
|
|
174
170
|
type: 'list',
|
|
175
171
|
version: '1.2.3',
|
|
@@ -187,8 +183,8 @@ describe('iterBlock', () => {
|
|
|
187
183
|
});
|
|
188
184
|
describe('iterBlockList', () => {
|
|
189
185
|
it('should call the appropriate callbacks', () => {
|
|
190
|
-
const onBlock =
|
|
191
|
-
const onBlockList =
|
|
186
|
+
const onBlock = vi.fn();
|
|
187
|
+
const onBlockList = vi.fn();
|
|
192
188
|
const blocks = [
|
|
193
189
|
{
|
|
194
190
|
type: 'list',
|
|
@@ -206,8 +202,8 @@ describe('iterBlockList', () => {
|
|
|
206
202
|
expect(result).toBe(false);
|
|
207
203
|
});
|
|
208
204
|
it('should abort if onBlockList returns true', () => {
|
|
209
|
-
const onBlock =
|
|
210
|
-
const onBlockList =
|
|
205
|
+
const onBlock = vi.fn();
|
|
206
|
+
const onBlockList = vi.fn().mockReturnValue(true);
|
|
211
207
|
const blocks = [
|
|
212
208
|
{
|
|
213
209
|
type: 'list',
|
|
@@ -227,8 +223,8 @@ describe('iterBlockList', () => {
|
|
|
227
223
|
});
|
|
228
224
|
describe('iterPage', () => {
|
|
229
225
|
it('should iterate over a page', () => {
|
|
230
|
-
const onBlockList =
|
|
231
|
-
const onPage =
|
|
226
|
+
const onBlockList = vi.fn();
|
|
227
|
+
const onPage = vi.fn();
|
|
232
228
|
const page = {
|
|
233
229
|
name: 'Page',
|
|
234
230
|
blocks: [],
|
|
@@ -239,8 +235,8 @@ describe('iterPage', () => {
|
|
|
239
235
|
expect(result).toBe(false);
|
|
240
236
|
});
|
|
241
237
|
it('should abort if onPage returns true', () => {
|
|
242
|
-
const onBlockList =
|
|
243
|
-
const onPage =
|
|
238
|
+
const onBlockList = vi.fn();
|
|
239
|
+
const onPage = vi.fn().mockReturnValue(true);
|
|
244
240
|
const page = {
|
|
245
241
|
name: 'Page',
|
|
246
242
|
blocks: [],
|
|
@@ -251,8 +247,8 @@ describe('iterPage', () => {
|
|
|
251
247
|
expect(result).toBe(true);
|
|
252
248
|
});
|
|
253
249
|
it('should iterate a flow page', () => {
|
|
254
|
-
const onBlockList =
|
|
255
|
-
const onPage =
|
|
250
|
+
const onBlockList = vi.fn();
|
|
251
|
+
const onPage = vi.fn();
|
|
256
252
|
const page = {
|
|
257
253
|
name: 'Page',
|
|
258
254
|
type: 'flow',
|
|
@@ -269,8 +265,8 @@ describe('iterPage', () => {
|
|
|
269
265
|
expect(result).toBe(false);
|
|
270
266
|
});
|
|
271
267
|
it('should iterate a tabs page', () => {
|
|
272
|
-
const onBlockList =
|
|
273
|
-
const onPage =
|
|
268
|
+
const onBlockList = vi.fn();
|
|
269
|
+
const onPage = vi.fn();
|
|
274
270
|
const page = {
|
|
275
271
|
name: 'Page',
|
|
276
272
|
type: 'tabs',
|
|
@@ -287,8 +283,8 @@ describe('iterPage', () => {
|
|
|
287
283
|
expect(result).toBe(false);
|
|
288
284
|
});
|
|
289
285
|
it('should call onAction for page actions', () => {
|
|
290
|
-
const onAction =
|
|
291
|
-
const onPage =
|
|
286
|
+
const onAction = vi.fn();
|
|
287
|
+
const onPage = vi.fn();
|
|
292
288
|
const page = {
|
|
293
289
|
name: 'Page',
|
|
294
290
|
type: 'flow',
|
|
@@ -305,9 +301,9 @@ describe('iterPage', () => {
|
|
|
305
301
|
expect(result).toBe(false);
|
|
306
302
|
});
|
|
307
303
|
it('should call onAction and onBlockList for pages with actions and sub pages', () => {
|
|
308
|
-
const onAction =
|
|
309
|
-
const onPage =
|
|
310
|
-
const onBlockList =
|
|
304
|
+
const onAction = vi.fn();
|
|
305
|
+
const onPage = vi.fn();
|
|
306
|
+
const onBlockList = vi.fn();
|
|
311
307
|
const page = {
|
|
312
308
|
name: 'Page',
|
|
313
309
|
type: 'flow',
|
|
@@ -342,7 +338,7 @@ describe('iterPage', () => {
|
|
|
342
338
|
});
|
|
343
339
|
describe('iterApp', () => {
|
|
344
340
|
it('should iterate over the page of an app', () => {
|
|
345
|
-
const onPage =
|
|
341
|
+
const onPage = vi.fn();
|
|
346
342
|
const app = {
|
|
347
343
|
name: 'App',
|
|
348
344
|
defaultPage: 'Page',
|
|
@@ -358,7 +354,7 @@ describe('iterApp', () => {
|
|
|
358
354
|
expect(result).toBe(false);
|
|
359
355
|
});
|
|
360
356
|
it('should abort page iteration if a callback returns true', () => {
|
|
361
|
-
const onPage =
|
|
357
|
+
const onPage = vi.fn().mockReturnValue(true);
|
|
362
358
|
const app = {
|
|
363
359
|
name: 'App',
|
|
364
360
|
defaultPage: 'Page 1',
|
|
@@ -379,7 +375,7 @@ describe('iterApp', () => {
|
|
|
379
375
|
expect(result).toBe(true);
|
|
380
376
|
});
|
|
381
377
|
it('should iterate over cron jobs', () => {
|
|
382
|
-
const onAction =
|
|
378
|
+
const onAction = vi.fn();
|
|
383
379
|
const app = {
|
|
384
380
|
name: 'App',
|
|
385
381
|
defaultPage: 'Page 1',
|
|
@@ -396,7 +392,7 @@ describe('iterApp', () => {
|
|
|
396
392
|
expect(result).toBe(false);
|
|
397
393
|
});
|
|
398
394
|
it('should abort cron iteration if a callback returns true', () => {
|
|
399
|
-
const onAction =
|
|
395
|
+
const onAction = vi.fn().mockReturnValue(true);
|
|
400
396
|
const app = {
|
|
401
397
|
name: 'App',
|
|
402
398
|
defaultPage: 'Page 1',
|