-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add time support into datetime mask type (#5406)
* Add time support into datetime mask type surveyjs/survey-library#7997 * add help text * fix descriptions surveyjs/survey-library#7997 * Update packages/survey-creator-core/src/localization/english.ts Co-authored-by: RomanTsukanov <RomanTsukanov@users.noreply.github.com> --------- Co-authored-by: RomanTsukanov <RomanTsukanov@users.noreply.github.com>
- Loading branch information
1 parent
e79665e
commit 413710c
Showing
3 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/survey-creator-core/tests/property-grid/property-grid-mask-settings.tests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { QuestionTextModel } from "survey-core"; | ||
import { PropertyGridModelTester } from "./property-grid.base"; | ||
|
||
export * from "../../src/property-grid/maskSettings"; | ||
|
||
test("Mask settings updated if change mask type", () => { | ||
const question = new QuestionTextModel("q1"); | ||
const propertyGrid = new PropertyGridModelTester(question); | ||
const masksettingsQuestion = (propertyGrid.survey.getQuestionByName("maskSettings")); | ||
expect(masksettingsQuestion).toBeTruthy(); | ||
|
||
const panel = masksettingsQuestion.contentPanel; | ||
expect(panel.elements.map(e => e.name)).toStrictEqual(["saveMaskedValue", "preview"]); | ||
|
||
question.maskType = "datetime"; | ||
expect(panel.elements.map(e => e.name)).toStrictEqual(["pattern", "min", "max", "saveMaskedValue", "preview"]); | ||
|
||
question.maskType = "currency"; | ||
expect(panel.elements.map(e => e.name)).toStrictEqual([ | ||
"prefix", | ||
"suffix", | ||
"min", | ||
"max", | ||
"precision", | ||
"decimalSeparator", | ||
"thousandsSeparator", | ||
"allowNegativeValues", | ||
"saveMaskedValue", | ||
"preview"]); | ||
|
||
question.maskType = "none"; | ||
expect(panel.elements.map(e => e.name)).toStrictEqual(["saveMaskedValue", "preview"]); | ||
}); | ||
|
||
test("Mask settings DateTime Min/max input types", () => { | ||
const question = new QuestionTextModel("q1"); | ||
question.fromJSON({ | ||
"maskType": "datetime", | ||
"maskSettings": { | ||
"pattern": "mm/dd/yyyy HH:MM" | ||
} | ||
}); | ||
|
||
const propertyGrid = new PropertyGridModelTester(question); | ||
const masksettingsQuestion = (propertyGrid.survey.getQuestionByName("maskSettings")); | ||
expect(masksettingsQuestion).toBeTruthy(); | ||
|
||
const panel = masksettingsQuestion.contentPanel; | ||
const patternQuestion = panel.getQuestionByName("pattern"); | ||
const minQuestion = panel.getQuestionByName("min"); | ||
const maxQuestion = panel.getQuestionByName("max"); | ||
expect(patternQuestion.value).toBe("mm/dd/yyyy HH:MM"); | ||
expect(minQuestion.inputType).toBe("datetime-local"); | ||
expect(maxQuestion.inputType).toBe("datetime-local"); | ||
|
||
patternQuestion.value = "mm/dd/yyyy"; | ||
expect(minQuestion.inputType).toBe("date"); | ||
expect(maxQuestion.inputType).toBe("date"); | ||
|
||
patternQuestion.value = "HH:MM"; | ||
expect(minQuestion.inputType).toBe("time"); | ||
expect(maxQuestion.inputType).toBe("time"); | ||
|
||
patternQuestion.value = "hh:MM tt"; | ||
expect(minQuestion.inputType).toBe("time"); | ||
expect(maxQuestion.inputType).toBe("time"); | ||
}); |