-
Notifications
You must be signed in to change notification settings - Fork 11
feat(input_schema): datepicker allowAbsolute/allowRelative properties and validation #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
b073e36
3e1fd9f
2d26f34
23fef3d
aee4c0c
316f0a8
5716f07
3427325
4f983cb
a088af3
9f5928d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,5 +285,163 @@ describe('input_schema.json', () => { | |
| })).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('special cases for datepicker editor type', () => { | ||
| it('should accept allowAbsolute and allowRelative fields omitted', () => { | ||
| expect(ajv.validate(inputSchema, { | ||
| title: 'Test input schema', | ||
| type: 'object', | ||
| schemaVersion: 1, | ||
| properties: { | ||
| myField: { | ||
| title: 'Field title', | ||
| description: 'My test field', | ||
| type: 'string', | ||
| editor: 'datepicker', | ||
| }, | ||
| }, | ||
| })).toBe(true); | ||
| }); | ||
|
|
||
| it('should accept allowAbsolute and allowRelative both set to true', () => { | ||
| expect(ajv.validate(inputSchema, { | ||
| title: 'Test input schema', | ||
| type: 'object', | ||
| schemaVersion: 1, | ||
| properties: { | ||
| myField: { | ||
| title: 'Field title', | ||
| description: 'My test field', | ||
| type: 'string', | ||
| editor: 'datepicker', | ||
| allowAbsolute: true, | ||
| allowRelative: true, | ||
| }, | ||
| }, | ||
| })).toBe(true); | ||
| }); | ||
|
|
||
| it('should accept allowAbsolute=true and allowRelative=false', () => { | ||
| expect(ajv.validate(inputSchema, { | ||
| title: 'Test input schema', | ||
| type: 'object', | ||
| schemaVersion: 1, | ||
| properties: { | ||
| myField: { | ||
| title: 'Field title', | ||
| description: 'My test field', | ||
| type: 'string', | ||
| editor: 'datepicker', | ||
| allowAbsolute: true, | ||
| allowRelative: false, | ||
| }, | ||
| }, | ||
| })).toBe(true); | ||
| }); | ||
|
|
||
| it('should accept allowAbsolute=false and allowRelative=true', () => { | ||
| expect(ajv.validate(inputSchema, { | ||
| title: 'Test input schema', | ||
| type: 'object', | ||
| schemaVersion: 1, | ||
| properties: { | ||
| myField: { | ||
| title: 'Field title', | ||
| description: 'My test field', | ||
| type: 'string', | ||
| editor: 'datepicker', | ||
| allowAbsolute: false, | ||
| allowRelative: true, | ||
| }, | ||
| }, | ||
| })).toBe(true); | ||
| }); | ||
|
|
||
| it('should accept allowAbsolute=true', () => { | ||
| expect(ajv.validate(inputSchema, { | ||
| title: 'Test input schema', | ||
| type: 'object', | ||
| schemaVersion: 1, | ||
| properties: { | ||
| myField: { | ||
| title: 'Field title', | ||
| description: 'My test field', | ||
| type: 'string', | ||
| editor: 'datepicker', | ||
| allowAbsolute: true, | ||
| }, | ||
| }, | ||
| })).toBe(true); | ||
| }); | ||
|
|
||
| it('should accept allowRelative=true', () => { | ||
| expect(ajv.validate(inputSchema, { | ||
| title: 'Test input schema', | ||
| type: 'object', | ||
| schemaVersion: 1, | ||
| properties: { | ||
| myField: { | ||
| title: 'Field title', | ||
| description: 'My test field', | ||
| type: 'string', | ||
| editor: 'datepicker', | ||
| allowRelative: true, | ||
| }, | ||
| }, | ||
| })).toBe(true); | ||
| }); | ||
|
|
||
| it('should accept allowRelative=false', () => { | ||
| expect(ajv.validate(inputSchema, { | ||
| title: 'Test input schema', | ||
| type: 'object', | ||
| schemaVersion: 1, | ||
| properties: { | ||
| myField: { | ||
| title: 'Field title', | ||
| description: 'My test field', | ||
| type: 'string', | ||
| editor: 'datepicker', | ||
| allowRelative: false, | ||
| }, | ||
| }, | ||
| })).toBe(true); | ||
| }); | ||
|
|
||
| it('should not accept allowAbsolute=false', () => { | ||
| expect(ajv.validate(inputSchema, { | ||
| title: 'Test input schema', | ||
| type: 'object', | ||
| schemaVersion: 1, | ||
| properties: { | ||
| myField: { | ||
| title: 'Field title', | ||
| description: 'My test field', | ||
| type: 'string', | ||
| editor: 'datepicker', | ||
| allowAbsolute: false, | ||
| }, | ||
| }, | ||
| })).toBe(false); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather test if the error message is correct as the logic is not trivial. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added check of error messages |
||
| }); | ||
|
|
||
| it('should not accept allowAbsolute=false allowRelative=false', () => { | ||
| expect(ajv.validate(inputSchema, { | ||
| title: 'Test input schema', | ||
| type: 'object', | ||
| schemaVersion: 1, | ||
| properties: { | ||
| myField: { | ||
| title: 'Field title', | ||
| description: 'My test field', | ||
| type: 'string', | ||
| editor: 'datepicker', | ||
| allowAbsolute: false, | ||
| allowRelative: false, | ||
| }, | ||
| }, | ||
| })).toBe(false); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.