@dmptool/types 1.1.2 → 1.2.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.
- package/README.md +119 -47
- package/dist/answers/__tests__/answers.spec.js +20 -28
- package/dist/answers/__tests__/usage.spec.d.ts +1 -0
- package/dist/answers/__tests__/usage.spec.js +175 -0
- package/dist/answers/answer.d.ts +12 -15
- package/dist/answers/answer.js +3 -4
- package/dist/answers/dateAnswers.d.ts +30 -30
- package/dist/answers/dateAnswers.js +6 -5
- package/dist/answers/graphQLAnswers.d.ts +25 -25
- package/dist/answers/graphQLAnswers.js +4 -4
- package/dist/answers/index.d.ts +860 -1088
- package/dist/answers/index.js +2 -2
- package/dist/answers/numberAnswers.d.ts +41 -41
- package/dist/answers/numberAnswers.js +8 -8
- package/dist/answers/optionBasedAnswers.d.ts +55 -55
- package/dist/answers/optionBasedAnswers.js +10 -10
- package/dist/answers/tableAnswers.d.ts +811 -1772
- package/dist/answers/tableAnswers.js +12 -8
- package/dist/answers/textAnswers.d.ts +44 -44
- package/dist/answers/textAnswers.js +8 -8
- package/dist/questions/__tests__/graphQLQuestions.spec.js +6 -4
- package/dist/questions/__tests__/optionBasedQuestions.spec.js +4 -12
- package/dist/questions/__tests__/usage.spec.d.ts +8 -0
- package/dist/questions/__tests__/usage.spec.js +312 -0
- package/dist/questions/dateQuestions.d.ts +90 -101
- package/dist/questions/dateQuestions.js +15 -34
- package/dist/questions/graphQLQuestions.d.ts +176 -182
- package/dist/questions/graphQLQuestions.js +44 -45
- package/dist/questions/index.d.ts +1791 -2170
- package/dist/questions/index.js +2 -2
- package/dist/questions/numberQuestions.d.ts +126 -142
- package/dist/questions/numberQuestions.js +11 -45
- package/dist/questions/optionBasedQuestions.d.ts +197 -225
- package/dist/questions/optionBasedQuestions.js +24 -88
- package/dist/questions/question.d.ts +24 -56
- package/dist/questions/question.js +78 -18
- package/dist/questions/tableQuestions.d.ts +2637 -2930
- package/dist/questions/tableQuestions.js +9 -21
- package/dist/questions/textQuestions.d.ts +125 -145
- package/dist/questions/textQuestions.js +16 -57
- package/dist/schemas/affiliationSearchAnswer.schema.json +9 -12
- package/dist/schemas/affiliationSearchQuestion.schema.json +57 -50
- package/dist/schemas/anyAnswer.schema.json +228 -237
- package/dist/schemas/anyQuestion.schema.json +349 -517
- package/dist/schemas/anyTableColumnAnswer.schema.json +93 -106
- package/dist/schemas/anyTableColumnQuestion.schema.json +259 -382
- package/dist/schemas/booleanAnswer.schema.json +8 -11
- package/dist/schemas/booleanQuestion.schema.json +9 -15
- package/dist/schemas/checkboxesAnswer.schema.json +13 -14
- package/dist/schemas/checkboxesQuestion.schema.json +18 -24
- package/dist/schemas/currencyAnswer.schema.json +8 -11
- package/dist/schemas/currencyQuestion.schema.json +13 -17
- package/dist/schemas/dateAnswer.schema.json +8 -11
- package/dist/schemas/dateQuestion.schema.json +9 -15
- package/dist/schemas/dateRangeAnswer.schema.json +16 -21
- package/dist/schemas/dateRangeQuestion.schema.json +40 -21
- package/dist/schemas/emailAnswer.schema.json +8 -11
- package/dist/schemas/emailQuestion.schema.json +11 -16
- package/dist/schemas/filteredSearchQuestion.schema.json +0 -3
- package/dist/schemas/multiselectBoxAnswer.schema.json +13 -14
- package/dist/schemas/multiselectBoxQuestion.schema.json +20 -25
- package/dist/schemas/numberAnswer.schema.json +8 -11
- package/dist/schemas/numberQuestion.schema.json +11 -16
- package/dist/schemas/numberRangeAnswer.schema.json +17 -22
- package/dist/schemas/numberRangeQuestion.schema.json +22 -21
- package/dist/schemas/radioButtonsAnswer.schema.json +8 -11
- package/dist/schemas/radioButtonsQuestion.schema.json +18 -24
- package/dist/schemas/selectBoxAnswer.schema.json +8 -11
- package/dist/schemas/selectBoxQuestion.schema.json +20 -25
- package/dist/schemas/tableAnswer.schema.json +337 -343
- package/dist/schemas/tableQuestion.schema.json +279 -416
- package/dist/schemas/textAnswer.schema.json +8 -11
- package/dist/schemas/textAreaAnswer.schema.json +8 -11
- package/dist/schemas/textAreaQuestion.schema.json +13 -17
- package/dist/schemas/textQuestion.schema.json +9 -15
- package/dist/schemas/urlAnswer.schema.json +8 -11
- package/dist/schemas/urlQuestion.schema.json +9 -15
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TableAnswerSchema = exports.TableRowAnswerSchema = exports.
|
|
3
|
+
exports.TableAnswerSchema = exports.TableRowAnswerSchema = exports.AnyTableColumnAnswerSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const answer_1 = require("./answer");
|
|
6
6
|
const optionBasedAnswers_1 = require("./optionBasedAnswers");
|
|
@@ -8,6 +8,7 @@ const dateAnswers_1 = require("./dateAnswers");
|
|
|
8
8
|
const graphQLAnswers_1 = require("./graphQLAnswers");
|
|
9
9
|
const numberAnswers_1 = require("./numberAnswers");
|
|
10
10
|
const textAnswers_1 = require("./textAnswers");
|
|
11
|
+
const questions_1 = require("../questions");
|
|
11
12
|
// Answers to Table Column Question Types (note that TableAnswer is not included here because we don't allow nested tables)
|
|
12
13
|
exports.AnyTableColumnAnswerSchema = zod_1.z.discriminatedUnion('type', [
|
|
13
14
|
graphQLAnswers_1.AffiliationSearchAnswerSchema,
|
|
@@ -26,15 +27,18 @@ exports.AnyTableColumnAnswerSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
26
27
|
textAnswers_1.TextAreaAnswerSchema,
|
|
27
28
|
textAnswers_1.URLAnswerSchema
|
|
28
29
|
]);
|
|
29
|
-
exports.TableColumnAnswerSchema = zod_1.z.object({
|
|
30
|
-
heading: zod_1.z.string(), // The heading of the column
|
|
31
|
-
content: exports.AnyTableColumnAnswerSchema // The answer to the column (based on the type)
|
|
32
|
-
});
|
|
33
30
|
exports.TableRowAnswerSchema = zod_1.z.object({
|
|
34
|
-
columns: zod_1.z.array(exports.
|
|
31
|
+
columns: zod_1.z.array(exports.AnyTableColumnAnswerSchema) // The answers for each column in the row
|
|
35
32
|
});
|
|
36
33
|
// Answers to Table Question Types
|
|
37
34
|
exports.TableAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
38
|
-
type: zod_1.z.literal('table'),
|
|
39
|
-
|
|
35
|
+
type: zod_1.z.literal('table'),
|
|
36
|
+
columnHeadings: zod_1.z.array(zod_1.z.string()).default(['Column A']),
|
|
37
|
+
answer: zod_1.z.array(exports.TableRowAnswerSchema).default([{
|
|
38
|
+
columns: [{
|
|
39
|
+
type: 'textArea',
|
|
40
|
+
answer: '',
|
|
41
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
42
|
+
}]
|
|
43
|
+
}])
|
|
40
44
|
}));
|
|
@@ -1,99 +1,99 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const EmailAnswerSchema: z.ZodObject<{
|
|
3
|
-
meta: z.ZodObject<{
|
|
4
|
-
schemaVersion: z.
|
|
3
|
+
meta: z.ZodDefault<z.ZodObject<{
|
|
4
|
+
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
5
5
|
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
schemaVersion:
|
|
6
|
+
schemaVersion: string;
|
|
7
7
|
}, {
|
|
8
|
-
schemaVersion
|
|
9
|
-
}
|
|
8
|
+
schemaVersion?: string | undefined;
|
|
9
|
+
}>>;
|
|
10
10
|
} & {
|
|
11
11
|
type: z.ZodLiteral<"email">;
|
|
12
|
-
answer: z.ZodString
|
|
12
|
+
answer: z.ZodDefault<z.ZodString>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
14
|
type: "email";
|
|
15
15
|
meta: {
|
|
16
|
-
schemaVersion:
|
|
16
|
+
schemaVersion: string;
|
|
17
17
|
};
|
|
18
18
|
answer: string;
|
|
19
19
|
}, {
|
|
20
20
|
type: "email";
|
|
21
|
-
meta
|
|
22
|
-
schemaVersion
|
|
23
|
-
};
|
|
24
|
-
answer
|
|
21
|
+
meta?: {
|
|
22
|
+
schemaVersion?: string | undefined;
|
|
23
|
+
} | undefined;
|
|
24
|
+
answer?: string | undefined;
|
|
25
25
|
}>;
|
|
26
26
|
export declare const TextAnswerSchema: z.ZodObject<{
|
|
27
|
-
meta: z.ZodObject<{
|
|
28
|
-
schemaVersion: z.
|
|
27
|
+
meta: z.ZodDefault<z.ZodObject<{
|
|
28
|
+
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
29
29
|
}, "strip", z.ZodTypeAny, {
|
|
30
|
-
schemaVersion:
|
|
30
|
+
schemaVersion: string;
|
|
31
31
|
}, {
|
|
32
|
-
schemaVersion
|
|
33
|
-
}
|
|
32
|
+
schemaVersion?: string | undefined;
|
|
33
|
+
}>>;
|
|
34
34
|
} & {
|
|
35
35
|
type: z.ZodLiteral<"text">;
|
|
36
|
-
answer: z.ZodString
|
|
36
|
+
answer: z.ZodDefault<z.ZodString>;
|
|
37
37
|
}, "strip", z.ZodTypeAny, {
|
|
38
38
|
type: "text";
|
|
39
39
|
meta: {
|
|
40
|
-
schemaVersion:
|
|
40
|
+
schemaVersion: string;
|
|
41
41
|
};
|
|
42
42
|
answer: string;
|
|
43
43
|
}, {
|
|
44
44
|
type: "text";
|
|
45
|
-
meta
|
|
46
|
-
schemaVersion
|
|
47
|
-
};
|
|
48
|
-
answer
|
|
45
|
+
meta?: {
|
|
46
|
+
schemaVersion?: string | undefined;
|
|
47
|
+
} | undefined;
|
|
48
|
+
answer?: string | undefined;
|
|
49
49
|
}>;
|
|
50
50
|
export declare const TextAreaAnswerSchema: z.ZodObject<{
|
|
51
|
-
meta: z.ZodObject<{
|
|
52
|
-
schemaVersion: z.
|
|
51
|
+
meta: z.ZodDefault<z.ZodObject<{
|
|
52
|
+
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
53
53
|
}, "strip", z.ZodTypeAny, {
|
|
54
|
-
schemaVersion:
|
|
54
|
+
schemaVersion: string;
|
|
55
55
|
}, {
|
|
56
|
-
schemaVersion
|
|
57
|
-
}
|
|
56
|
+
schemaVersion?: string | undefined;
|
|
57
|
+
}>>;
|
|
58
58
|
} & {
|
|
59
59
|
type: z.ZodLiteral<"textArea">;
|
|
60
|
-
answer: z.ZodString
|
|
60
|
+
answer: z.ZodDefault<z.ZodString>;
|
|
61
61
|
}, "strip", z.ZodTypeAny, {
|
|
62
62
|
type: "textArea";
|
|
63
63
|
meta: {
|
|
64
|
-
schemaVersion:
|
|
64
|
+
schemaVersion: string;
|
|
65
65
|
};
|
|
66
66
|
answer: string;
|
|
67
67
|
}, {
|
|
68
68
|
type: "textArea";
|
|
69
|
-
meta
|
|
70
|
-
schemaVersion
|
|
71
|
-
};
|
|
72
|
-
answer
|
|
69
|
+
meta?: {
|
|
70
|
+
schemaVersion?: string | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
answer?: string | undefined;
|
|
73
73
|
}>;
|
|
74
74
|
export declare const URLAnswerSchema: z.ZodObject<{
|
|
75
|
-
meta: z.ZodObject<{
|
|
76
|
-
schemaVersion: z.
|
|
75
|
+
meta: z.ZodDefault<z.ZodObject<{
|
|
76
|
+
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
77
77
|
}, "strip", z.ZodTypeAny, {
|
|
78
|
-
schemaVersion:
|
|
78
|
+
schemaVersion: string;
|
|
79
79
|
}, {
|
|
80
|
-
schemaVersion
|
|
81
|
-
}
|
|
80
|
+
schemaVersion?: string | undefined;
|
|
81
|
+
}>>;
|
|
82
82
|
} & {
|
|
83
83
|
type: z.ZodLiteral<"url">;
|
|
84
|
-
answer: z.ZodString
|
|
84
|
+
answer: z.ZodDefault<z.ZodString>;
|
|
85
85
|
}, "strip", z.ZodTypeAny, {
|
|
86
86
|
type: "url";
|
|
87
87
|
meta: {
|
|
88
|
-
schemaVersion:
|
|
88
|
+
schemaVersion: string;
|
|
89
89
|
};
|
|
90
90
|
answer: string;
|
|
91
91
|
}, {
|
|
92
92
|
type: "url";
|
|
93
|
-
meta
|
|
94
|
-
schemaVersion
|
|
95
|
-
};
|
|
96
|
-
answer
|
|
93
|
+
meta?: {
|
|
94
|
+
schemaVersion?: string | undefined;
|
|
95
|
+
} | undefined;
|
|
96
|
+
answer?: string | undefined;
|
|
97
97
|
}>;
|
|
98
98
|
export type EmailAnswerType = z.infer<typeof EmailAnswerSchema>;
|
|
99
99
|
export type TextAnswerType = z.infer<typeof TextAnswerSchema>;
|
|
@@ -5,18 +5,18 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const answer_1 = require("./answer");
|
|
6
6
|
// Answers to Text Based Question Types
|
|
7
7
|
exports.EmailAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
8
|
-
type: zod_1.z.literal('email'),
|
|
9
|
-
answer: zod_1.z.string()
|
|
8
|
+
type: zod_1.z.literal('email'),
|
|
9
|
+
answer: zod_1.z.string().default('')
|
|
10
10
|
}));
|
|
11
11
|
exports.TextAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
12
|
-
type: zod_1.z.literal('text'),
|
|
13
|
-
answer: zod_1.z.string()
|
|
12
|
+
type: zod_1.z.literal('text'),
|
|
13
|
+
answer: zod_1.z.string().default('')
|
|
14
14
|
}));
|
|
15
15
|
exports.TextAreaAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
16
|
-
type: zod_1.z.literal('textArea'),
|
|
17
|
-
answer: zod_1.z.string()
|
|
16
|
+
type: zod_1.z.literal('textArea'),
|
|
17
|
+
answer: zod_1.z.string().default('')
|
|
18
18
|
}));
|
|
19
19
|
exports.URLAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
20
|
-
type: zod_1.z.literal('url'),
|
|
21
|
-
answer: zod_1.z.string()
|
|
20
|
+
type: zod_1.z.literal('url'),
|
|
21
|
+
answer: zod_1.z.string().default('')
|
|
22
22
|
}));
|
|
@@ -57,16 +57,18 @@ const graphQLQuestions_1 = require("../graphQLQuestions");
|
|
|
57
57
|
type: "affiliationSearch",
|
|
58
58
|
attributes: {
|
|
59
59
|
label: "Search",
|
|
60
|
-
help: "Search for a
|
|
60
|
+
help: "Search for a institution",
|
|
61
61
|
},
|
|
62
62
|
graphQL: {
|
|
63
|
+
query: graphQLQuestions_1.affiliationQuery,
|
|
63
64
|
displayFields: [
|
|
64
|
-
{ propertyName: "
|
|
65
|
+
{ propertyName: "displayName", label: "Name" },
|
|
65
66
|
],
|
|
66
67
|
localQueryId: "12345",
|
|
67
|
-
|
|
68
|
+
answerField: "uri",
|
|
69
|
+
responseField: "affiliations.items",
|
|
68
70
|
variables: [
|
|
69
|
-
{ name: "
|
|
71
|
+
{ type: "string", name: "name", label: "Term", minLength: 3 },
|
|
70
72
|
],
|
|
71
73
|
},
|
|
72
74
|
meta: {
|
|
@@ -3,18 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const globals_1 = require("@jest/globals");
|
|
4
4
|
const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
5
5
|
(0, globals_1.describe)("BooleanQuestion", () => {
|
|
6
|
-
(0, globals_1.it)('optional fields should not throw an error if the value is undefined', () => {
|
|
7
|
-
const validBooleanQuestion = {
|
|
8
|
-
type: "boolean",
|
|
9
|
-
meta: {
|
|
10
|
-
schemaVersion: "1.0",
|
|
11
|
-
},
|
|
12
|
-
attributes: {
|
|
13
|
-
checked: undefined, // Valid value
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
(0, globals_1.expect)(() => optionBasedQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
|
|
17
|
-
});
|
|
18
6
|
(0, globals_1.it)('optional fields should throw an error if the value is null', () => {
|
|
19
7
|
const invalidBooleanQuestion = {
|
|
20
8
|
type: "boolean",
|
|
@@ -69,6 +57,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
69
57
|
{
|
|
70
58
|
label: "Banana",
|
|
71
59
|
value: "banana",
|
|
60
|
+
checked: false,
|
|
72
61
|
},
|
|
73
62
|
],
|
|
74
63
|
meta: {
|
|
@@ -115,6 +104,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
115
104
|
{
|
|
116
105
|
label: "Female",
|
|
117
106
|
value: "female",
|
|
107
|
+
selected: true,
|
|
118
108
|
},
|
|
119
109
|
],
|
|
120
110
|
meta: {
|
|
@@ -158,6 +148,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
158
148
|
{
|
|
159
149
|
label: "Canada",
|
|
160
150
|
value: "ca",
|
|
151
|
+
selected: false,
|
|
161
152
|
},
|
|
162
153
|
],
|
|
163
154
|
meta: {
|
|
@@ -205,6 +196,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
205
196
|
{
|
|
206
197
|
label: "Canada",
|
|
207
198
|
value: "ca",
|
|
199
|
+
selected: false,
|
|
208
200
|
},
|
|
209
201
|
],
|
|
210
202
|
meta: {
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const question_1 = require("../question");
|
|
4
|
+
const index_1 = require("../index");
|
|
5
|
+
// Parse the Zod schema with no input to generate the default JSON schemas
|
|
6
|
+
function questionFormatInfo(name) {
|
|
7
|
+
if (name in index_1.QuestionSchemaMap) {
|
|
8
|
+
const usage = question_1.QuestionFormatsUsage[name];
|
|
9
|
+
const schema = index_1.QuestionSchemaMap[name];
|
|
10
|
+
const parsedSchema = schema.parse({ type: name });
|
|
11
|
+
return {
|
|
12
|
+
type: name,
|
|
13
|
+
title: usage === null || usage === void 0 ? void 0 : usage.title,
|
|
14
|
+
usageDescription: usage === null || usage === void 0 ? void 0 : usage.usageDescription,
|
|
15
|
+
defaultJSON: parsedSchema
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
describe('Get question format information', () => {
|
|
23
|
+
it('for affiliationSearch question format', () => {
|
|
24
|
+
const format = questionFormatInfo('affiliationSearch');
|
|
25
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('affiliationSearch');
|
|
26
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Affiliation Search');
|
|
27
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
28
|
+
const expectedJSON = {
|
|
29
|
+
type: 'affiliationSearch',
|
|
30
|
+
attributes: {},
|
|
31
|
+
meta: { schemaVersion: '1.0' },
|
|
32
|
+
graphQL: {
|
|
33
|
+
displayFields: [{
|
|
34
|
+
label: "Institution",
|
|
35
|
+
propertyName: "displayName",
|
|
36
|
+
}],
|
|
37
|
+
query: index_1.affiliationQuery,
|
|
38
|
+
responseField: 'affiliations.items',
|
|
39
|
+
variables: [{
|
|
40
|
+
label: "Search for your institution",
|
|
41
|
+
minLength: 3,
|
|
42
|
+
name: "name",
|
|
43
|
+
type: "string",
|
|
44
|
+
}],
|
|
45
|
+
answerField: 'uri'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
49
|
+
});
|
|
50
|
+
it('for boolean question format', () => {
|
|
51
|
+
const format = questionFormatInfo('boolean');
|
|
52
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('boolean');
|
|
53
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Yes/No Field');
|
|
54
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
55
|
+
const expectedJSON = {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
attributes: { checked: false },
|
|
58
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
59
|
+
};
|
|
60
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
61
|
+
});
|
|
62
|
+
it('for checkBoxes question format', () => {
|
|
63
|
+
const format = questionFormatInfo('checkBoxes');
|
|
64
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('checkBoxes');
|
|
65
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Check Boxes');
|
|
66
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
67
|
+
const expectedJSON = {
|
|
68
|
+
type: 'checkBoxes',
|
|
69
|
+
attributes: {},
|
|
70
|
+
options: [{
|
|
71
|
+
label: 'Option A',
|
|
72
|
+
value: 'a',
|
|
73
|
+
checked: false
|
|
74
|
+
}],
|
|
75
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
76
|
+
};
|
|
77
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
78
|
+
});
|
|
79
|
+
it('for currency question format', () => {
|
|
80
|
+
const format = questionFormatInfo('currency');
|
|
81
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('currency');
|
|
82
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Currency Field');
|
|
83
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
84
|
+
const expectedJSON = {
|
|
85
|
+
type: 'currency',
|
|
86
|
+
attributes: {
|
|
87
|
+
denomination: 'USD',
|
|
88
|
+
min: 0,
|
|
89
|
+
step: 1
|
|
90
|
+
},
|
|
91
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
92
|
+
};
|
|
93
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
it('for date question format', () => {
|
|
97
|
+
const format = questionFormatInfo('date');
|
|
98
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('date');
|
|
99
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Date Field');
|
|
100
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
101
|
+
const expectedJSON = {
|
|
102
|
+
type: 'date',
|
|
103
|
+
attributes: {
|
|
104
|
+
step: 1
|
|
105
|
+
},
|
|
106
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
107
|
+
};
|
|
108
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
109
|
+
});
|
|
110
|
+
it('for dateRange question format', () => {
|
|
111
|
+
const format = questionFormatInfo('dateRange');
|
|
112
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('dateRange');
|
|
113
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Date Range');
|
|
114
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
115
|
+
const expectedJSON = {
|
|
116
|
+
type: 'dateRange',
|
|
117
|
+
attributes: {},
|
|
118
|
+
columns: {
|
|
119
|
+
start: {
|
|
120
|
+
label: 'From',
|
|
121
|
+
step: 1
|
|
122
|
+
},
|
|
123
|
+
end: {
|
|
124
|
+
label: 'To',
|
|
125
|
+
step: 1
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
129
|
+
};
|
|
130
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
131
|
+
});
|
|
132
|
+
it('for email question format', () => {
|
|
133
|
+
const format = questionFormatInfo('email');
|
|
134
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('email');
|
|
135
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Email Field');
|
|
136
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
137
|
+
const expectedJSON = {
|
|
138
|
+
type: 'email',
|
|
139
|
+
attributes: {
|
|
140
|
+
maxLength: 255,
|
|
141
|
+
multiple: false,
|
|
142
|
+
},
|
|
143
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
144
|
+
};
|
|
145
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
146
|
+
});
|
|
147
|
+
it('for multiselectBox question format', () => {
|
|
148
|
+
const format = questionFormatInfo('multiselectBox');
|
|
149
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('multiselectBox');
|
|
150
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Multi-select Box');
|
|
151
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
152
|
+
const expectedJSON = {
|
|
153
|
+
type: 'multiselectBox',
|
|
154
|
+
attributes: {
|
|
155
|
+
multiple: true,
|
|
156
|
+
},
|
|
157
|
+
options: [{
|
|
158
|
+
label: 'Option A',
|
|
159
|
+
value: 'a',
|
|
160
|
+
selected: false
|
|
161
|
+
}],
|
|
162
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
163
|
+
};
|
|
164
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
165
|
+
});
|
|
166
|
+
it('for number question format', () => {
|
|
167
|
+
const format = questionFormatInfo('number');
|
|
168
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('number');
|
|
169
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Number Field');
|
|
170
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
171
|
+
const expectedJSON = {
|
|
172
|
+
type: 'number',
|
|
173
|
+
attributes: {
|
|
174
|
+
min: 0,
|
|
175
|
+
step: 1,
|
|
176
|
+
},
|
|
177
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
178
|
+
};
|
|
179
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
180
|
+
});
|
|
181
|
+
it('for numberRange format', () => {
|
|
182
|
+
const format = questionFormatInfo('numberRange');
|
|
183
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('numberRange');
|
|
184
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Number Range');
|
|
185
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
186
|
+
const expectedJSON = {
|
|
187
|
+
type: 'numberRange',
|
|
188
|
+
attributes: {},
|
|
189
|
+
columns: {
|
|
190
|
+
start: {
|
|
191
|
+
label: 'From',
|
|
192
|
+
min: 0,
|
|
193
|
+
step: 1,
|
|
194
|
+
},
|
|
195
|
+
end: {
|
|
196
|
+
label: 'To',
|
|
197
|
+
min: 0,
|
|
198
|
+
step: 1,
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
202
|
+
};
|
|
203
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
204
|
+
});
|
|
205
|
+
it('for radioButtons question format', () => {
|
|
206
|
+
const format = questionFormatInfo('radioButtons');
|
|
207
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('radioButtons');
|
|
208
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Radio Buttons');
|
|
209
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
210
|
+
const expectedJSON = {
|
|
211
|
+
type: 'radioButtons',
|
|
212
|
+
attributes: {},
|
|
213
|
+
options: [{
|
|
214
|
+
label: 'Option A',
|
|
215
|
+
value: 'a',
|
|
216
|
+
selected: false
|
|
217
|
+
}],
|
|
218
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
219
|
+
};
|
|
220
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
221
|
+
});
|
|
222
|
+
it('for selectBox question format', () => {
|
|
223
|
+
const format = questionFormatInfo('selectBox');
|
|
224
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('selectBox');
|
|
225
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Select Box');
|
|
226
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
227
|
+
const expectedJSON = {
|
|
228
|
+
type: 'selectBox',
|
|
229
|
+
attributes: {
|
|
230
|
+
multiple: false,
|
|
231
|
+
},
|
|
232
|
+
options: [{
|
|
233
|
+
label: 'Option A',
|
|
234
|
+
value: 'a',
|
|
235
|
+
selected: false
|
|
236
|
+
}],
|
|
237
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
238
|
+
};
|
|
239
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
240
|
+
});
|
|
241
|
+
it('for table question format', () => {
|
|
242
|
+
const format = questionFormatInfo('table');
|
|
243
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('table');
|
|
244
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Table');
|
|
245
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
246
|
+
const expectedJSON = {
|
|
247
|
+
type: 'table',
|
|
248
|
+
attributes: {
|
|
249
|
+
canAddRows: true,
|
|
250
|
+
canRemoveRows: true,
|
|
251
|
+
initialRows: 1
|
|
252
|
+
},
|
|
253
|
+
columns: [{
|
|
254
|
+
heading: 'Column A',
|
|
255
|
+
content: {
|
|
256
|
+
type: 'textArea',
|
|
257
|
+
attributes: {
|
|
258
|
+
asRichText: true,
|
|
259
|
+
cols: 20,
|
|
260
|
+
rows: 2,
|
|
261
|
+
},
|
|
262
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION }
|
|
263
|
+
}
|
|
264
|
+
}],
|
|
265
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
266
|
+
};
|
|
267
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
268
|
+
});
|
|
269
|
+
it('for text question format', () => {
|
|
270
|
+
const format = questionFormatInfo('text');
|
|
271
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('text');
|
|
272
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Text Field');
|
|
273
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
274
|
+
const expectedJSON = {
|
|
275
|
+
type: 'text',
|
|
276
|
+
attributes: {
|
|
277
|
+
maxLength: 255,
|
|
278
|
+
},
|
|
279
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
280
|
+
};
|
|
281
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
282
|
+
});
|
|
283
|
+
it('for textArea question format', () => {
|
|
284
|
+
const format = questionFormatInfo('textArea');
|
|
285
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('textArea');
|
|
286
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('Text Area');
|
|
287
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
288
|
+
const expectedJSON = {
|
|
289
|
+
type: 'textArea',
|
|
290
|
+
attributes: {
|
|
291
|
+
asRichText: true,
|
|
292
|
+
cols: 20,
|
|
293
|
+
rows: 2,
|
|
294
|
+
},
|
|
295
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
296
|
+
};
|
|
297
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
298
|
+
});
|
|
299
|
+
it('for url question format', () => {
|
|
300
|
+
const format = questionFormatInfo('url');
|
|
301
|
+
expect(format === null || format === void 0 ? void 0 : format.type).toEqual('url');
|
|
302
|
+
expect(format === null || format === void 0 ? void 0 : format.title).toEqual('URL Field');
|
|
303
|
+
expect(format === null || format === void 0 ? void 0 : format.usageDescription).toBeDefined();
|
|
304
|
+
const expectedJSON = {
|
|
305
|
+
type: 'url',
|
|
306
|
+
attributes: {
|
|
307
|
+
maxLength: 255,
|
|
308
|
+
},
|
|
309
|
+
meta: { schemaVersion: question_1.CURRENT_SCHEMA_VERSION },
|
|
310
|
+
};
|
|
311
|
+
expect(format === null || format === void 0 ? void 0 : format.defaultJSON).toEqual(expectedJSON);
|
|
312
|
+
});
|