@kbss-cvut/s-forms 0.4.1 → 0.4.2-alpha-f760ea7.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/css/s-forms.min.css +1 -0
- package/dist/s-forms.cjs.map +1 -1
- package/dist/s-forms.js.map +1 -1
- package/dist/s-forms.modern.js.map +1 -1
- package/dist/s-forms.umd.js.map +1 -1
- package/package.json +20 -10
- package/{dist → types}/components/Answer.d.ts +0 -0
- package/{dist → types}/components/DefaultInput.d.ts +0 -0
- package/{dist → types}/components/FormManager.d.ts +0 -0
- package/{dist → types}/components/FormWindow.d.ts +0 -0
- package/{dist → types}/components/HelpIcon.d.ts +0 -0
- package/{dist → types}/components/IconOverlay.d.ts +0 -0
- package/{dist → types}/components/LinkIcon.d.ts +0 -0
- package/{dist → types}/components/MaskedInput.d.ts +0 -0
- package/{dist → types}/components/MediaContent.d.ts +0 -0
- package/{dist → types}/components/PrefixIcon.d.ts +0 -0
- package/{dist → types}/components/Question.d.ts +0 -0
- package/{dist → types}/components/QuestionStatic.d.ts +0 -0
- package/{dist → types}/components/SForms.d.ts +0 -0
- package/{dist → types}/components/answer/CheckboxAnswer.d.ts +0 -0
- package/{dist → types}/components/answer/DateTimeAnswer.d.ts +0 -0
- package/{dist → types}/components/answer/InputAnswer.d.ts +0 -0
- package/{dist → types}/components/answer/MaskedInputAnswer.d.ts +0 -0
- package/{dist → types}/components/answer/OptimizedMenuList.d.ts +0 -0
- package/{dist → types}/components/answer/SelectAnswer.d.ts +0 -0
- package/{dist → types}/components/answer/TypeaheadAnswer.d.ts +0 -0
- package/{dist → types}/components/comment/CommentForm.d.ts +0 -0
- package/{dist → types}/components/comment/CommentList.d.ts +0 -0
- package/{dist → types}/components/comment/CommentView.d.ts +0 -0
- package/{dist → types}/components/comment/QuestionCommentIcon.d.ts +0 -0
- package/{dist → types}/components/wizard/HorizontalWizardNav.d.ts +0 -0
- package/{dist → types}/components/wizard/VerticalWizardNav.d.ts +0 -0
- package/{dist → types}/components/wizard/Wizard.d.ts +0 -0
- package/{dist → types}/components/wizard/WizardStep.d.ts +0 -0
- package/{dist → types}/constants/Constants.d.ts +0 -0
- package/{dist → types}/contexts/ConfigurationContext.d.ts +0 -0
- package/{dist → types}/contexts/FormGenContext.d.ts +0 -0
- package/{dist → types}/contexts/FormQuestionsContext.d.ts +0 -0
- package/{dist → types}/contexts/IntlContextProvider.d.ts +2 -2
- package/{dist → types}/model/DefaultFormGenerator.d.ts +0 -0
- package/{dist → types}/model/FormGenerator.d.ts +0 -0
- package/{dist → types}/model/QuestionAnswerProcessor.d.ts +0 -0
- package/{dist → types}/model/ValidatorFactory.d.ts +0 -0
- package/types/s-forms.d.ts +16 -216
- package/{dist → types}/stories/Answer.stories.d.ts +0 -0
- package/{dist → types}/stories/CommentForm.stories.d.ts +0 -0
- package/{dist → types}/stories/HelpIcon.stories.d.ts +0 -0
- package/{dist → types}/stories/LinkIcon.stories.d.ts +0 -0
- package/{dist → types}/stories/MediaContent.stories.d.ts +0 -0
- package/{dist → types}/stories/PrefixIcon.stories.d.ts +0 -0
- package/{dist → types}/stories/Question.stories.d.ts +0 -0
- package/{dist → types}/stories/QuestionCommentIcon.stories.d.ts +0 -0
- package/{dist → types}/stories/SForms.stories.d.ts +0 -0
- package/{dist → types}/styles/icons/ArrowRight.d.ts +0 -0
- package/{dist → types}/styles/icons/CaretSquareDown.d.ts +0 -0
- package/{dist → types}/styles/icons/CaretSquareUp.d.ts +0 -0
- package/{dist → types}/styles/icons/Close.d.ts +0 -0
- package/{dist → types}/styles/icons/CommentBubble.d.ts +0 -0
- package/{dist → types}/styles/icons/ExternalLink.d.ts +0 -0
- package/{dist → types}/styles/icons/InfoCircle.d.ts +0 -0
- package/{dist → types}/styles/icons/QuestionCircle.d.ts +0 -0
- package/{dist → types}/styles/icons/RecycleBin.d.ts +0 -0
- package/{dist → types}/styles/icons/index.d.ts +0 -0
- package/{dist → types}/util/FormUtils.d.ts +0 -0
- package/{dist → types}/util/JsonLdFramingUtils.d.ts +0 -0
- package/{dist → types}/util/JsonLdObjectMap.d.ts +0 -0
- package/{dist → types}/util/JsonLdObjectUtils.d.ts +0 -0
- package/{dist → types}/util/Logger.d.ts +0 -0
- package/{dist → types}/util/MaskMapper.d.ts +0 -0
- package/{dist → types}/util/Utils.d.ts +0 -0
- package/.babelrc +0 -22
- package/.github/workflows/check-format.yml +0 -21
- package/.github/workflows/chromatic.yml +0 -24
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -4
- package/.storybook/main.cjs +0 -11
- package/.storybook/preview.js +0 -103
- package/dist/s-forms.css +0 -2
- package/dist/s-forms.css.map +0 -1
- package/dist/s-forms.d.ts +0 -16
- package/jest.config.cjs +0 -20
- package/test/__mocks__/styleMock.js +0 -1
- package/test/__tests__/Answer.test.js +0 -399
- package/test/__tests__/DefaultFormGenerator.test.js +0 -34
- package/test/__tests__/FormUtils.test.js +0 -297
- package/test/__tests__/InputAnswer.test.js +0 -193
- package/test/__tests__/JsonLdFramingUtils.test.js +0 -29
- package/test/__tests__/JsonLdObjectUtils.test.js +0 -86
- package/test/__tests__/MaskMapper.test.js +0 -32
- package/test/__tests__/MaskedInputAnswer.test.js +0 -90
- package/test/__tests__/Question.test.js +0 -102
- package/test/__tests__/QuestionAnswerProcessor.test.js +0 -183
- package/test/__tests__/QuestionCommentIcon.test.js +0 -77
- package/test/__tests__/TypeheadAnswer.test.js +0 -102
- package/test/environment/Generator.js +0 -44
- package/test/setup.js +0 -19
- package/tsconfig.json +0 -20
package/.storybook/preview.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import Constants from "../src/constants/Constants";
|
|
2
|
-
import { addDecorator } from "@storybook/react";
|
|
3
|
-
import IntlContextProvider from "../src/contexts/IntlContextProvider";
|
|
4
|
-
import { FormGenContextProvider } from "../src/contexts/FormGenContext";
|
|
5
|
-
import { ConfigurationContextProvider } from "../src/contexts/ConfigurationContext";
|
|
6
|
-
|
|
7
|
-
import "react-datepicker/dist/react-datepicker.css";
|
|
8
|
-
import "bootstrap/dist/css/bootstrap.min.css";
|
|
9
|
-
import "../src/styles/s-forms.css";
|
|
10
|
-
import possibleValues from "../src/stories/assets/possibleValues.json";
|
|
11
|
-
|
|
12
|
-
export const parameters = {
|
|
13
|
-
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
14
|
-
controls: {
|
|
15
|
-
matchers: {
|
|
16
|
-
color: /(background|color)$/i,
|
|
17
|
-
date: /Date$/,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const globalTypes = {
|
|
23
|
-
iconBehavior: {
|
|
24
|
-
name: "Icon behavior",
|
|
25
|
-
description: "Set the behavior for the icons",
|
|
26
|
-
defaultValue: Constants.ICON_BEHAVIOR.ON_HOVER,
|
|
27
|
-
options: [
|
|
28
|
-
Constants.ICON_BEHAVIOR.ON_HOVER,
|
|
29
|
-
Constants.ICON_BEHAVIOR.ENABLE,
|
|
30
|
-
Constants.ICON_BEHAVIOR.DISABLE,
|
|
31
|
-
],
|
|
32
|
-
control: { type: "radio" },
|
|
33
|
-
},
|
|
34
|
-
locale: {
|
|
35
|
-
name: "Locale",
|
|
36
|
-
description: "Internationalization locale",
|
|
37
|
-
defaultValue: "en",
|
|
38
|
-
options: ["en", "cs"],
|
|
39
|
-
control: { type: "radio" },
|
|
40
|
-
},
|
|
41
|
-
debugMode: {
|
|
42
|
-
name: "Debug Mode",
|
|
43
|
-
description: "Show irrelevant questions",
|
|
44
|
-
defaultValue: false,
|
|
45
|
-
control: { type: "boolean" },
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const options = {
|
|
50
|
-
i18n: {
|
|
51
|
-
"wizard.next": "Next",
|
|
52
|
-
"wizard.previous": "Previous",
|
|
53
|
-
"section.expand": "Expand",
|
|
54
|
-
"section.collapse": "Collapse",
|
|
55
|
-
},
|
|
56
|
-
intl: {
|
|
57
|
-
locale: "en",
|
|
58
|
-
},
|
|
59
|
-
modalView: false,
|
|
60
|
-
horizontalWizardNav: false,
|
|
61
|
-
wizardStepButtons: true,
|
|
62
|
-
enableForwardSkip: true,
|
|
63
|
-
startingStep: 1,
|
|
64
|
-
debugMode: false,
|
|
65
|
-
users: [
|
|
66
|
-
{ id: "http://fel.cvut.cz/people/max-chopart", label: "Max Chopart" },
|
|
67
|
-
{
|
|
68
|
-
id: "http://fel.cvut.cz/people/miroslav-blasko",
|
|
69
|
-
label: "Miroslav Blasko",
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
currentUser: "http://fel.cvut.cz/people/max-chopart",
|
|
73
|
-
icons: [
|
|
74
|
-
{
|
|
75
|
-
id: Constants.ICONS.QUESTION_HELP,
|
|
76
|
-
behavior: Constants.ICON_BEHAVIOR.ENABLE,
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: Constants.ICONS.QUESTION_LINK,
|
|
80
|
-
behavior: Constants.ICON_BEHAVIOR.ENABLE,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
id: Constants.ICONS.QUESTION_COMMENTS,
|
|
84
|
-
behavior: Constants.ICON_BEHAVIOR.ENABLE,
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const fetchTypeAheadValues = () => {
|
|
90
|
-
return new Promise((resolve) =>
|
|
91
|
-
setTimeout(() => resolve(possibleValues), 1500)
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
addDecorator((story) => (
|
|
96
|
-
<ConfigurationContextProvider options={options}>
|
|
97
|
-
<FormGenContextProvider fetchTypeAheadValues={fetchTypeAheadValues}>
|
|
98
|
-
<IntlContextProvider locale={globalTypes.locale.defaultValue}>
|
|
99
|
-
{story()}
|
|
100
|
-
</IntlContextProvider>
|
|
101
|
-
</FormGenContextProvider>
|
|
102
|
-
</ConfigurationContextProvider>
|
|
103
|
-
));
|
package/dist/s-forms.css
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
.checkbox label{font-weight:700}.panel-title .checkbox label{font-weight:400}.answerable-question{background-color:#e6f9fb;border:1px solid #dfdfdf;border-bottom-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;color:#000;padding:.75rem 1.25rem}.answerable-subquestions{border:1px solid #dfdfdf;border-bottom-left-radius:4px;border-bottom-right-radius:4px;margin-bottom:1.11rem;padding:1rem}.answerable-question .form-group{margin-bottom:0}.answerable-question .form-group .form-check-input{margin-top:.37rem}.answerable-section .form-group .form-check-label{font-weight:500;margin-left:.11rem}.answerable-section .card-header .col-10{flex-basis:auto;padding-right:0;width:auto}.overlay-comment{position:absolute;z-index:10}svg{fill:currentColor}.comment-delete,.question-comment{cursor:pointer}.caret-square-down,.caret-square-up,.info-circle,.question-circle,.question-comment{height:1rem;margin-bottom:.15rem}.close-icon,.external-link-icon,.question-circle,.question-comment,.recycle-bin-icon{fill:grey}.text-white .external-link-icon,.text-white .question-circle,.text-white .question-comment{fill:#fff}.caret-square-down,.caret-square-up{margin-left:-.3125rem;margin-right:.2rem}.has-unit-label{font-weight:700;margin-left:.75rem;margin-top:.75rem}.tooltip-content{white-space:pre-wrap}.collapse-toggle{line-height:.9;margin-right:.3rem}.form-label{font-weight:500;white-space:nowrap}input:disabled{cursor:not-allowed}.cursor-pointer{cursor:pointer}.accordion>.card{overflow:visible}.react-datepicker-wrapper{display:block}.react-datepicker__navigation:focus{outline:none}.wizard-step{min-height:40.625rem}.wizard-step-content{min-height:37.5rem}.list-group-item.active{font-weight:500}.question-category-1{background-color:rgba(8,255,0,.05)}.question-category-2{background-color:rgba(230,127,0,.05)}.question-category-3{background-color:rgba(222,0,230,.05)}.question-category-4{background-color:rgba(0,84,230,.05)}.question-category-5{background-color:rgba(0,230,222,.05)}.answer{align-items:center;display:flex;position:relative}.answer>.answer-content{flex-grow:1;max-width:31.25rem}.card-header{min-height:3rem}.card-header:first-child{line-height:24px}.card-header.bg-info{background-color:#e6f9fb!important}.card-header.section-background{background-color:#e6f9fb}.question-header{align-items:center;display:flex}.question-header h6{margin:0}.icon-list-items{display:flex;margin:0;padding-left:0}.icon-list-item{list-style-type:none}.card-header .form-group{margin-bottom:0}.emphasise-on-relevant-icon{-webkit-animation:emphasiseOnRelevantIcon .5s ease-in;animation:emphasiseOnRelevantIcon .5s ease-in}.emphasise-on-relevant{-webkit-animation:emphasiseOnRelevant 1.2s ease-in;animation:emphasiseOnRelevant 1.2s ease-in}.card-header.emphasise-on-relevant{-webkit-animation:emphasiseOnRelevantSection 1.2s ease-in;animation:emphasiseOnRelevantSection 1.2s ease-in}.comment-tooltip>.tooltip-inner{background-color:#cbeef6;border:2px solid #afafaf;border-radius:0;color:#000;max-width:none;padding:0;width:30vw}.close-comment-icon{cursor:pointer;height:24px;margin-left:auto;width:24px}#comment-form{display:flex;width:100%}#comment-form textarea{overflow-y:hidden;resize:none}.comment-form-control{border-radius:0}.btn.comment-form-button{align-items:center;bottom:2px;display:flex;height:25px;justify-content:center;padding:0;position:absolute;right:2px;width:25px}.comment-content{padding:.5rem;text-align:left}.comment-delete{align-items:center;display:flex;flex-direction:column;justify-content:center}.comment-content .comment-author{font-weight:700}.comment-content .comment-value{white-space:pre-line}.comment-list-items{max-height:25rem;overflow:hidden scroll}.comment-timestamp{color:#696969;font-style:italic}.comment-badge{bottom:13px;font-size:.5625rem;position:relative;right:7px}.show-irrelevant{opacity:50%}.show-irrelevant,.show-irrelevant .form-check-input,.show-irrelevant .form-check-label{pointer-events:none}.show-irrelevant .card-header,.show-irrelevant.list-group-item{pointer-events:auto}@-webkit-keyframes emphasiseOnRelevant{0%{display:none;opacity:0}1%{background-color:#ff0;display:block;opacity:0}25%{display:block;opacity:0}75%{display:block;opacity:1}to{background-color:transparent;display:block;opacity:1}}@keyframes emphasiseOnRelevant{0%{display:none;opacity:0}1%{background-color:#ff0;display:block;opacity:0}25%{display:block;opacity:0}75%{display:block;opacity:1}to{background-color:transparent;display:block;opacity:1}}@-webkit-keyframes emphasiseOnRelevantSection{0%{display:none;opacity:0}1%{background-color:#ff0;display:block;opacity:0}25%{display:block;opacity:0}75%{display:block;opacity:1}to{background-color:#e6f9fb;display:block;opacity:1}}@keyframes emphasiseOnRelevantSection{0%{display:none;opacity:0}1%{background-color:#ff0;display:block;opacity:0}25%{display:block;opacity:0}75%{display:block;opacity:1}to{background-color:#e6f9fb;display:block;opacity:1}}@-webkit-keyframes emphasiseOnRelevantIcon{0%{display:none;opacity:0}1%{display:block;opacity:0}25%{display:block;opacity:0}75%{display:block;opacity:1}to{background-color:transparent;display:block;opacity:1}}@keyframes emphasiseOnRelevantIcon{0%{display:none;opacity:0}1%{display:block;opacity:0}25%{display:block;opacity:0}75%{display:block;opacity:1}to{background-color:transparent;display:block;opacity:1}}
|
|
2
|
-
/*# sourceMappingURL=s-forms.css.map */
|
package/dist/s-forms.css.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["s-forms.css"],"names":[],"mappings":"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","file":"s-forms.css","sourcesContent":[".checkbox label {\n font-weight: bold;\n}\n\n.panel-title .checkbox label {\n font-weight: normal;\n}\n\n.answerable-question {\n color: black;\n background-color: #e6f9fb;\n border: 1px solid #dfdfdf;\n border-bottom: 1px solid transparent;\n border-top-right-radius: 3px;\n border-top-left-radius: 3px;\n padding: 0.75rem 1.25rem;\n}\n\n.answerable-subquestions {\n padding: 1rem;\n border: 1px solid #dfdfdf;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n margin-bottom: 1.11rem;\n}\n\n.answerable-question .form-group {\n margin-bottom: 0;\n}\n\n.answerable-question .form-group .form-check-input {\n margin-top: 0.37rem;\n}\n\n.answerable-section .form-group .form-check-label {\n margin-left: 0.11rem;\n font-weight: 500;\n}\n\n.answerable-section .card-header .col-10 {\n width: auto;\n flex-basis: auto;\n padding-right: 0;\n}\n\n.overlay-comment {\n position: absolute;\n z-index: 10;\n}\n\nsvg {\n fill: currentColor;\n}\n\n.question-comment,\n.comment-delete {\n cursor: pointer;\n}\n\n.caret-square-up,\n.caret-square-down,\n.question-circle,\n.question-comment,\n.info-circle {\n height: 1rem;\n margin-bottom: 0.15rem;\n}\n\n.question-circle,\n.question-comment,\n.external-link-icon,\n.close-icon,\n.recycle-bin-icon {\n fill: grey;\n}\n\n.text-white .question-circle,\n.text-white .question-comment,\n.text-white .external-link-icon {\n fill: white;\n}\n\n.caret-square-up,\n.caret-square-down {\n margin-right: 0.2rem;\n margin-left: -0.3125rem;\n}\n\n.has-unit-label {\n font-weight: bold;\n margin-top: 0.75rem;\n margin-left: 0.75rem;\n}\n\n.tooltip-content {\n white-space: pre-wrap;\n}\n\n.collapse-toggle {\n margin-right: 0.3rem;\n line-height: 0.9;\n}\n\n.form-label {\n font-weight: 500;\n white-space: nowrap;\n}\n\ninput:disabled {\n cursor: not-allowed;\n}\n\n.cursor-pointer {\n cursor: pointer;\n}\n\n.accordion > .card {\n overflow: visible;\n}\n\n.react-datepicker-wrapper {\n display: block;\n}\n\n.react-datepicker__navigation:focus {\n outline: none;\n}\n\n.wizard-step {\n min-height: 40.625rem;\n}\n\n.wizard-step-content {\n min-height: 37.5rem;\n}\n\n.list-group-item.active {\n font-weight: 500;\n}\n\n.question-category-1 {\n background-color: rgba(8, 255, 0, 0.05);\n}\n\n.question-category-2 {\n background-color: rgba(230, 127, 0, 0.05);\n}\n\n.question-category-3 {\n background-color: rgba(222, 0, 230, 0.05);\n}\n\n.question-category-4 {\n background-color: rgba(0, 84, 230, 0.05);\n}\n\n.question-category-5 {\n background-color: rgba(0, 230, 222, 0.05);\n}\n\n.answer {\n display: flex;\n position: relative;\n align-items: center;\n}\n\n.answer > .answer-content {\n flex-grow: 1;\n max-width: 31.25rem;\n}\n\n.card-header {\n min-height: 3rem;\n}\n\n.card-header:first-child {\n line-height: 24px;\n}\n\n.card-header.bg-info {\n background-color: #e6f9fb !important;\n}\n\n.card-header.section-background {\n background-color: #e6f9fb;\n}\n\n.question-header {\n display: flex;\n align-items: center;\n}\n\n.question-header h6 {\n margin: 0;\n}\n\n.icon-list-items {\n display: flex;\n padding-left: 0;\n margin: 0;\n}\n\n.icon-list-item {\n list-style-type: none;\n}\n\n.card-header .form-group {\n margin-bottom: 0;\n}\n\n.emphasise-on-relevant-icon {\n animation: emphasiseOnRelevantIcon 0.5s ease-in;\n}\n\n.emphasise-on-relevant {\n animation: emphasiseOnRelevant 1.2s ease-in;\n}\n\n.card-header.emphasise-on-relevant {\n animation: emphasiseOnRelevantSection 1.2s ease-in;\n}\n\n.comment-tooltip > .tooltip-inner {\n max-width: none;\n width: 30vw;\n border: solid 2px #afafaf;\n background-color: #cbeef6;\n color: #000000;\n padding: 0;\n border-radius: 0;\n}\n\n.close-comment-icon {\n cursor: pointer;\n height: 24px;\n width: 24px;\n margin-left: auto;\n}\n\n#comment-form {\n display: flex;\n width: 100%;\n}\n\n#comment-form textarea {\n resize: none;\n overflow-y: hidden;\n}\n\n.comment-form-control {\n border-radius: 0;\n}\n\n.btn.comment-form-button {\n position: absolute;\n display: flex;\n justify-content: center;\n align-items: center;\n right: 2px;\n bottom: 2px;\n height: 25px;\n width: 25px;\n padding: 0;\n}\n\n.comment-content {\n text-align: left;\n padding: 0.5rem;\n}\n\n.comment-delete {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.comment-content .comment-author {\n font-weight: bold;\n}\n\n.comment-content .comment-value {\n white-space: pre-line;\n}\n\n.comment-list-items {\n overflow: hidden scroll;\n max-height: 25rem;\n}\n\n.comment-timestamp {\n color: #696969;\n font-style: italic;\n}\n\n.comment-badge {\n position: relative;\n bottom: 13px;\n right: 7px;\n font-size: 0.5625rem;\n}\n\n.show-irrelevant {\n opacity: 50%;\n pointer-events: none;\n}\n\n.show-irrelevant .form-check-input,\n.show-irrelevant .form-check-label {\n pointer-events: none;\n}\n\n.show-irrelevant .card-header,\n.show-irrelevant.list-group-item {\n pointer-events: auto;\n}\n\n@keyframes emphasiseOnRelevant {\n 0% {\n display: none;\n opacity: 0;\n }\n\n 1% {\n display: block;\n opacity: 0;\n background-color: yellow;\n }\n\n 25% {\n display: block;\n opacity: 0;\n }\n\n 75% {\n display: block;\n opacity: 1;\n }\n\n 100% {\n display: block;\n opacity: 1;\n background-color: transparent;\n }\n}\n\n@keyframes emphasiseOnRelevantSection {\n 0% {\n display: none;\n opacity: 0;\n }\n\n 1% {\n display: block;\n opacity: 0;\n background-color: yellow;\n }\n\n 25% {\n display: block;\n opacity: 0;\n }\n\n 75% {\n display: block;\n opacity: 1;\n }\n\n 100% {\n display: block;\n opacity: 1;\n background-color: #e6f9fb;\n }\n}\n\n@keyframes emphasiseOnRelevantIcon {\n 0% {\n display: none;\n opacity: 0;\n }\n\n 1% {\n display: block;\n opacity: 0;\n }\n\n 25% {\n display: block;\n opacity: 0;\n }\n\n 75% {\n display: block;\n opacity: 1;\n }\n\n 100% {\n display: block;\n opacity: 1;\n background-color: transparent;\n }\n}\n"]}
|
package/dist/s-forms.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default SForms;
|
|
2
|
-
import SForms from "./components/SForms";
|
|
3
|
-
import Constants from "./constants/Constants";
|
|
4
|
-
import JsonLdObjectUtils from "./util/JsonLdObjectUtils";
|
|
5
|
-
import JsonLdFramingUtils from "./util/JsonLdFramingUtils";
|
|
6
|
-
import JsonLdObjectMap from "./util/JsonLdObjectMap";
|
|
7
|
-
import FormUtils from "./util/FormUtils";
|
|
8
|
-
import Question from "./components/Question";
|
|
9
|
-
import Answer from "./components/Answer";
|
|
10
|
-
import HelpIcon from "./components/HelpIcon";
|
|
11
|
-
import { ConfigurationContext } from "./contexts/ConfigurationContext";
|
|
12
|
-
import { FormQuestionsContext } from "./contexts/FormQuestionsContext";
|
|
13
|
-
import WizardStep from "./components/wizard/WizardStep";
|
|
14
|
-
import QuestionStatic from "./components/QuestionStatic";
|
|
15
|
-
import IntlContextProvider from "./contexts/IntlContextProvider.js";
|
|
16
|
-
export { Constants, JsonLdObjectUtils, JsonLdFramingUtils, JsonLdObjectMap, FormUtils, Question, Answer, HelpIcon, ConfigurationContext, FormQuestionsContext, WizardStep, QuestionStatic, IntlContextProvider };
|
package/jest.config.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
roots: ["<rootDir>"],
|
|
3
|
-
moduleFileExtensions: ["js", "jsx", "json", "ts", "tsx"],
|
|
4
|
-
setupFiles: ["<rootDir>/test/setup.js"],
|
|
5
|
-
transformIgnorePatterns: ["[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$"],
|
|
6
|
-
testEnvironment: "jsdom",
|
|
7
|
-
testURL: "http://localhost",
|
|
8
|
-
transform: {
|
|
9
|
-
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
|
|
10
|
-
},
|
|
11
|
-
reporters: ["default"],
|
|
12
|
-
moduleNameMapper: {
|
|
13
|
-
"\\.(css)$": "<rootDir>/test/__mocks__/styleMock.js",
|
|
14
|
-
},
|
|
15
|
-
globals: {
|
|
16
|
-
"s-forms": {
|
|
17
|
-
tsconfig: "tsconfig.spec.json",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { format } from "date-fns";
|
|
3
|
-
import DatePicker from "react-datepicker";
|
|
4
|
-
import Select from "react-select";
|
|
5
|
-
|
|
6
|
-
import * as Generator from "../environment/Generator";
|
|
7
|
-
import Answer from "../../src/components/Answer";
|
|
8
|
-
import Constants from "../../src/constants/Constants";
|
|
9
|
-
import TypeaheadAnswer from "../../src/components/answer/TypeaheadAnswer";
|
|
10
|
-
import MaskedInput from "../../src/components/MaskedInput";
|
|
11
|
-
import { FormGenContext } from "../../src/contexts/FormGenContext";
|
|
12
|
-
import { ConfigurationContext } from "../../src/contexts/ConfigurationContext";
|
|
13
|
-
import DefaultInput from "../../src/components/DefaultInput";
|
|
14
|
-
|
|
15
|
-
describe("Answer component", () => {
|
|
16
|
-
let question,
|
|
17
|
-
onChange,
|
|
18
|
-
answer,
|
|
19
|
-
getOptions,
|
|
20
|
-
loadFormOptions,
|
|
21
|
-
options,
|
|
22
|
-
inputComponent,
|
|
23
|
-
componentsOptions;
|
|
24
|
-
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
question = {
|
|
27
|
-
"@id": Generator.getRandomUri(),
|
|
28
|
-
};
|
|
29
|
-
question[Constants.LAYOUT_CLASS] = [];
|
|
30
|
-
question[Constants.RDFS_LABEL] = {
|
|
31
|
-
"@language": "en",
|
|
32
|
-
"@value": "1 - Aerodrome General",
|
|
33
|
-
};
|
|
34
|
-
question[Constants.RDFS_COMMENT] = {
|
|
35
|
-
"@language": "en",
|
|
36
|
-
"@value":
|
|
37
|
-
"The identification of the aerodrome/helicopter landing area by name, location and status.",
|
|
38
|
-
};
|
|
39
|
-
onChange = jest.fn();
|
|
40
|
-
options = {
|
|
41
|
-
intl: {
|
|
42
|
-
locale: "en",
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
componentsOptions = {
|
|
46
|
-
readOnly: false,
|
|
47
|
-
dateTimeAnswer: {
|
|
48
|
-
dateFormat: "yyyy-MM-dd",
|
|
49
|
-
timeFormat: "HH:mm:ss",
|
|
50
|
-
dateTimeFormat: "yyyy-MM-dd HH:mm:ss",
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
inputComponent = DefaultInput;
|
|
54
|
-
getOptions = jest.fn(() => []);
|
|
55
|
-
loadFormOptions = jest.fn();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("renders a Typeahead when layout class is typeahead", () => {
|
|
59
|
-
question[Constants.LAYOUT_CLASS].push(Constants.LAYOUT.QUESTION_TYPEAHEAD);
|
|
60
|
-
const component = mount(
|
|
61
|
-
<ConfigurationContext.Provider
|
|
62
|
-
value={{
|
|
63
|
-
componentsOptions,
|
|
64
|
-
inputComponent,
|
|
65
|
-
options,
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
<FormGenContext.Provider value={{ getOptions, loadFormOptions }}>
|
|
69
|
-
<Answer answer={{}} question={question} onChange={onChange} />
|
|
70
|
-
</FormGenContext.Provider>
|
|
71
|
-
</ConfigurationContext.Provider>
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
const typeahead = component.find(Select);
|
|
75
|
-
expect(typeahead).not.toBeNull();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("maps answer object value to string label for the typeahead component", () => {
|
|
79
|
-
const value = Generator.getRandomUri();
|
|
80
|
-
const valueLabel = "masterchief";
|
|
81
|
-
const typeAheadOptions = Generator.generateTypeaheadOptions(
|
|
82
|
-
value,
|
|
83
|
-
valueLabel
|
|
84
|
-
);
|
|
85
|
-
answer = answerWithCodeValue(value);
|
|
86
|
-
getOptions = jest.fn(() => typeAheadOptions);
|
|
87
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
88
|
-
question[Constants.LAYOUT_CLASS].push(Constants.LAYOUT.QUESTION_TYPEAHEAD);
|
|
89
|
-
question[Constants.HAS_OPTIONS_QUERY] = "SELECT * WHERE {?x ?y ?z. }";
|
|
90
|
-
|
|
91
|
-
const component = mount(
|
|
92
|
-
<ConfigurationContext.Provider
|
|
93
|
-
value={{
|
|
94
|
-
componentsOptions,
|
|
95
|
-
inputComponent,
|
|
96
|
-
options,
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
<FormGenContext.Provider
|
|
100
|
-
value={{ getOptions, loadFormOptions: () => typeAheadOptions }}
|
|
101
|
-
>
|
|
102
|
-
<Answer answer={answer} question={question} onChange={onChange} />
|
|
103
|
-
</FormGenContext.Provider>
|
|
104
|
-
</ConfigurationContext.Provider>
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
waitForComponentToPaint(component);
|
|
108
|
-
const typeahead = component.find(Answer).find(TypeaheadAnswer).find(Select);
|
|
109
|
-
|
|
110
|
-
expect(typeahead).not.toBeNull();
|
|
111
|
-
|
|
112
|
-
expect(typeahead.state("value")[0].name).toEqual(valueLabel);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("loads typeahead options when layout class is typeahead and no possible values are specified", () => {
|
|
116
|
-
question[Constants.LAYOUT_CLASS].push(Constants.LAYOUT.QUESTION_TYPEAHEAD);
|
|
117
|
-
const query = "SELECT * WHERE { ?x ?y ?z .}";
|
|
118
|
-
question[Constants.HAS_OPTIONS_QUERY] = query;
|
|
119
|
-
|
|
120
|
-
const component = mount(
|
|
121
|
-
<ConfigurationContext.Provider
|
|
122
|
-
value={{
|
|
123
|
-
componentsOptions,
|
|
124
|
-
inputComponent,
|
|
125
|
-
options,
|
|
126
|
-
}}
|
|
127
|
-
>
|
|
128
|
-
<FormGenContext.Provider value={{ getOptions, loadFormOptions }}>
|
|
129
|
-
<Answer answer={{}} question={question} onChange={onChange} />
|
|
130
|
-
</FormGenContext.Provider>
|
|
131
|
-
</ConfigurationContext.Provider>
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
waitForComponentToPaint(component);
|
|
135
|
-
|
|
136
|
-
expect(loadFormOptions).toHaveBeenCalled();
|
|
137
|
-
expect(loadFormOptions.mock.calls[0][1]).toEqual(query);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
function answerWithCodeValue(value) {
|
|
141
|
-
const res = {
|
|
142
|
-
"@id": Generator.getRandomUri(),
|
|
143
|
-
};
|
|
144
|
-
res[Constants.HAS_OBJECT_VALUE] = {
|
|
145
|
-
"@id": value,
|
|
146
|
-
};
|
|
147
|
-
return res;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
it("shows input with text value of the answer when no layout class is specified", () => {
|
|
151
|
-
const value = "masterchief";
|
|
152
|
-
answer = answerWithTextValue(value);
|
|
153
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
154
|
-
|
|
155
|
-
const component = mount(
|
|
156
|
-
<ConfigurationContext.Provider
|
|
157
|
-
value={{
|
|
158
|
-
componentsOptions,
|
|
159
|
-
inputComponent,
|
|
160
|
-
options,
|
|
161
|
-
}}
|
|
162
|
-
>
|
|
163
|
-
<Answer answer={answer} question={question} onChange={onChange} />s
|
|
164
|
-
</ConfigurationContext.Provider>
|
|
165
|
-
);
|
|
166
|
-
const input = component.find("input");
|
|
167
|
-
|
|
168
|
-
expect(input).not.toBeNull();
|
|
169
|
-
expect(input.props().type).toEqual("text");
|
|
170
|
-
expect(input.props().value).toEqual(value);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
function answerWithTextValue(value) {
|
|
174
|
-
const res = {
|
|
175
|
-
"@id": Generator.getRandomUri(),
|
|
176
|
-
};
|
|
177
|
-
res[Constants.HAS_DATA_VALUE] = {
|
|
178
|
-
"@language": "en",
|
|
179
|
-
"@value": value,
|
|
180
|
-
};
|
|
181
|
-
return res;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
it("renders date picker with answer value when date layout class is specified", () => {
|
|
185
|
-
const date = new Date("2000-01-01");
|
|
186
|
-
const value = format(date, "yyyy-MM-dd HH:mm:ss");
|
|
187
|
-
|
|
188
|
-
answer = answerWithTextValue(value);
|
|
189
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
190
|
-
question[Constants.LAYOUT_CLASS].push(Constants.LAYOUT.DATE);
|
|
191
|
-
|
|
192
|
-
const component = mount(
|
|
193
|
-
<ConfigurationContext.Provider
|
|
194
|
-
value={{
|
|
195
|
-
componentsOptions,
|
|
196
|
-
inputComponent,
|
|
197
|
-
options,
|
|
198
|
-
}}
|
|
199
|
-
>
|
|
200
|
-
<Answer answer={answer} question={question} onChange={onChange} />
|
|
201
|
-
</ConfigurationContext.Provider>
|
|
202
|
-
);
|
|
203
|
-
const picker = component.find(DatePicker);
|
|
204
|
-
|
|
205
|
-
expect(picker).not.toBeNull();
|
|
206
|
-
expect(picker.props().showTimeSelect).toEqual(false);
|
|
207
|
-
expect(picker.props().showTimeSelectOnly).toEqual(false);
|
|
208
|
-
expect(picker.props().selected).toEqual(date);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("renders time picker with answer value when time layout class is specified", () => {
|
|
212
|
-
const date = new Date();
|
|
213
|
-
const value = format(date, "HH:mm:ss");
|
|
214
|
-
|
|
215
|
-
answer = answerWithTextValue(value);
|
|
216
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
217
|
-
question[Constants.LAYOUT_CLASS].push(Constants.LAYOUT.TIME);
|
|
218
|
-
|
|
219
|
-
const component = mount(
|
|
220
|
-
<ConfigurationContext.Provider
|
|
221
|
-
value={{
|
|
222
|
-
componentsOptions,
|
|
223
|
-
inputComponent,
|
|
224
|
-
options,
|
|
225
|
-
}}
|
|
226
|
-
>
|
|
227
|
-
<Answer answer={answer} question={question} onChange={onChange} />
|
|
228
|
-
</ConfigurationContext.Provider>
|
|
229
|
-
);
|
|
230
|
-
const picker = component.find(DatePicker);
|
|
231
|
-
|
|
232
|
-
expect(picker).not.toBeNull();
|
|
233
|
-
expect(picker.props().showTimeSelect).toEqual(true);
|
|
234
|
-
expect(picker.props().showTimeSelectOnly).toEqual(true);
|
|
235
|
-
expect(picker.props().selected).toEqual(new Date(`0 ${value}`));
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("renders datetime picker with answer value when datetime layout class is specified", () => {
|
|
239
|
-
const date = new Date();
|
|
240
|
-
const value = format(date, "yyyy-MM-dd HH:mm:ss");
|
|
241
|
-
answer = answerWithTextValue(value);
|
|
242
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
243
|
-
question[Constants.LAYOUT_CLASS].push(Constants.LAYOUT.DATETIME);
|
|
244
|
-
|
|
245
|
-
const component = mount(
|
|
246
|
-
<ConfigurationContext.Provider
|
|
247
|
-
value={{
|
|
248
|
-
componentsOptions,
|
|
249
|
-
inputComponent,
|
|
250
|
-
options,
|
|
251
|
-
}}
|
|
252
|
-
>
|
|
253
|
-
<Answer answer={answer} question={question} onChange={onChange} />
|
|
254
|
-
</ConfigurationContext.Provider>
|
|
255
|
-
);
|
|
256
|
-
const picker = component.find(DatePicker);
|
|
257
|
-
|
|
258
|
-
expect(picker).not.toBeNull();
|
|
259
|
-
expect(picker.props().showTimeSelect).toEqual(true);
|
|
260
|
-
expect(picker.props().showTimeSelectOnly).toEqual(false);
|
|
261
|
-
expect(picker.props().selected).toEqual(new Date(value));
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("renders datetime picker with answer value when no layout class is specified and numeric answer value is used", () => {
|
|
265
|
-
const value = Number(new Date());
|
|
266
|
-
answer = {
|
|
267
|
-
"@id": Generator.getRandomUri(),
|
|
268
|
-
};
|
|
269
|
-
answer[Constants.HAS_DATA_VALUE] = value;
|
|
270
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
271
|
-
question[Constants.LAYOUT_CLASS].push(Constants.LAYOUT.DATETIME);
|
|
272
|
-
|
|
273
|
-
const component = mount(
|
|
274
|
-
<ConfigurationContext.Provider
|
|
275
|
-
value={{
|
|
276
|
-
componentsOptions,
|
|
277
|
-
inputComponent: { inputComponent },
|
|
278
|
-
options,
|
|
279
|
-
}}
|
|
280
|
-
>
|
|
281
|
-
<Answer answer={answer} question={question} onChange={onChange} />
|
|
282
|
-
</ConfigurationContext.Provider>
|
|
283
|
-
);
|
|
284
|
-
const picker = component.find(DatePicker);
|
|
285
|
-
|
|
286
|
-
expect(picker).not.toBeNull();
|
|
287
|
-
expect(picker.props().showTimeSelect).toEqual(true);
|
|
288
|
-
expect(picker.props().showTimeSelectOnly).toEqual(false);
|
|
289
|
-
expect(picker.props().selected).toEqual(new Date(value));
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it("renders checkbox with answer value when checkbox layout class is specified", () => {
|
|
293
|
-
const answer = {
|
|
294
|
-
"@id": Generator.getRandomUri(),
|
|
295
|
-
};
|
|
296
|
-
answer[Constants.HAS_DATA_VALUE] = true;
|
|
297
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
298
|
-
question[Constants.LAYOUT_CLASS].push(Constants.LAYOUT.CHECKBOX);
|
|
299
|
-
|
|
300
|
-
const component = mount(
|
|
301
|
-
<ConfigurationContext.Provider
|
|
302
|
-
value={{
|
|
303
|
-
componentsOptions,
|
|
304
|
-
inputComponent,
|
|
305
|
-
options,
|
|
306
|
-
}}
|
|
307
|
-
>
|
|
308
|
-
<Answer answer={answer} question={question} onChange={onChange} />
|
|
309
|
-
</ConfigurationContext.Provider>
|
|
310
|
-
);
|
|
311
|
-
const input = component.find("input");
|
|
312
|
-
|
|
313
|
-
expect(input).toBeDefined();
|
|
314
|
-
expect(input.props().type).toEqual("checkbox");
|
|
315
|
-
expect(input.props().checked).toBeTruthy();
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it("renders numeric input with answer value when number layout class is specified", () => {
|
|
319
|
-
const value = 117;
|
|
320
|
-
const answer = {
|
|
321
|
-
"@id": Generator.getRandomUri(),
|
|
322
|
-
};
|
|
323
|
-
answer[Constants.HAS_DATA_VALUE] = value;
|
|
324
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
325
|
-
question[Constants.HAS_DATATYPE] = Constants.XSD.INT;
|
|
326
|
-
|
|
327
|
-
const component = mount(
|
|
328
|
-
<ConfigurationContext.Provider
|
|
329
|
-
value={{
|
|
330
|
-
componentsOptions,
|
|
331
|
-
inputComponent,
|
|
332
|
-
options,
|
|
333
|
-
}}
|
|
334
|
-
>
|
|
335
|
-
<Answer answer={answer} question={question} onChange={onChange} />
|
|
336
|
-
</ConfigurationContext.Provider>
|
|
337
|
-
);
|
|
338
|
-
const input = component.find("input");
|
|
339
|
-
|
|
340
|
-
expect(input).toBeDefined();
|
|
341
|
-
expect(input.props().type).toEqual("number");
|
|
342
|
-
expect(input.props().value).toEqual(value);
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it("renders textarea for answer with long value", () => {
|
|
346
|
-
let value = "";
|
|
347
|
-
for (let i = 0; i < Constants.INPUT_LENGTH_THRESHOLD + 1; i++) {
|
|
348
|
-
value += "a";
|
|
349
|
-
}
|
|
350
|
-
answer = answerWithTextValue(value);
|
|
351
|
-
answer[Constants.HAS_DATA_VALUE] = value;
|
|
352
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
353
|
-
|
|
354
|
-
const component = mount(
|
|
355
|
-
<ConfigurationContext.Provider
|
|
356
|
-
value={{
|
|
357
|
-
componentsOptions,
|
|
358
|
-
inputComponent,
|
|
359
|
-
options,
|
|
360
|
-
}}
|
|
361
|
-
>
|
|
362
|
-
<Answer answer={answer} question={question} onChange={onChange} />
|
|
363
|
-
</ConfigurationContext.Provider>
|
|
364
|
-
);
|
|
365
|
-
const input = component.find("textarea");
|
|
366
|
-
|
|
367
|
-
expect(input).toBeDefined();
|
|
368
|
-
expect(input.props().value).toEqual(value);
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
it("renders masked input for question with masked-input layout class", () => {
|
|
372
|
-
const value = "08/2016";
|
|
373
|
-
const mask = "11/1111";
|
|
374
|
-
const answer = {
|
|
375
|
-
"@id": Generator.getRandomUri(),
|
|
376
|
-
};
|
|
377
|
-
answer[Constants.HAS_DATA_VALUE] = value;
|
|
378
|
-
question[Constants.HAS_ANSWER] = [answer];
|
|
379
|
-
question[Constants.LAYOUT_CLASS].push(Constants.LAYOUT.MASKED_INPUT);
|
|
380
|
-
question[Constants.INPUT_MASK] = mask;
|
|
381
|
-
|
|
382
|
-
const component = mount(
|
|
383
|
-
<ConfigurationContext.Provider
|
|
384
|
-
value={{
|
|
385
|
-
componentsOptions,
|
|
386
|
-
inputComponent,
|
|
387
|
-
options,
|
|
388
|
-
}}
|
|
389
|
-
>
|
|
390
|
-
<Answer answer={answer} question={question} onChange={onChange} />
|
|
391
|
-
</ConfigurationContext.Provider>
|
|
392
|
-
);
|
|
393
|
-
const input = component.find(MaskedInput);
|
|
394
|
-
|
|
395
|
-
expect(input).toBeDefined();
|
|
396
|
-
expect(input.props().value).toEqual(value);
|
|
397
|
-
expect(input.props().mask).toEqual(mask);
|
|
398
|
-
});
|
|
399
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import Constants from "../../src/constants/Constants";
|
|
2
|
-
import FormGenerator from "../../src/model/FormGenerator";
|
|
3
|
-
import DefaultFormGenerator from "../../src/model/DefaultFormGenerator";
|
|
4
|
-
|
|
5
|
-
describe("Default form generator", () => {
|
|
6
|
-
let textValue;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
textValue = "masterchief";
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("generates empty one-step wizard as a default form", async () => {
|
|
13
|
-
const form = DefaultFormGenerator.generateForm();
|
|
14
|
-
const [formQuestions, structure] = FormGenerator.constructDefaultForm(null);
|
|
15
|
-
|
|
16
|
-
expect(formQuestions.length).toEqual(1);
|
|
17
|
-
|
|
18
|
-
expect(structure).toEqual({ root: form["@graph"][0] });
|
|
19
|
-
|
|
20
|
-
expect(formQuestions[0][Constants.HAS_SUBQUESTION]).toEqual([
|
|
21
|
-
form["@graph"][0][Constants.HAS_SUBQUESTION][0][
|
|
22
|
-
Constants.HAS_SUBQUESTION
|
|
23
|
-
][0],
|
|
24
|
-
]);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("creates a clone of the form template, so that modifications to the form do not affect the original template", () => {
|
|
28
|
-
const formOne = DefaultFormGenerator.generateForm();
|
|
29
|
-
let formTwo;
|
|
30
|
-
formOne["newAttribute"] = 12345;
|
|
31
|
-
formTwo = DefaultFormGenerator.generateForm();
|
|
32
|
-
expect(formTwo["newAttribute"]).not.toBeDefined();
|
|
33
|
-
});
|
|
34
|
-
});
|