-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4049 from open-formulieren/issue/4038-filtering-f…
…or-geo-components Support filtering for GeoJSON-compatible schema properties
- Loading branch information
Showing
2 changed files
with
103 additions
and
8 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
77 changes: 77 additions & 0 deletions
77
src/openforms/js/components/admin/form_design/registrations/objectsapi/utils.spec.js
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,77 @@ | ||
import {EMPTY_VARIABLE} from 'components/admin/form_design/variables/constants'; | ||
|
||
import {asJsonSchema} from './utils'; | ||
|
||
test('JSON schema for single file upload component', () => { | ||
const component = { | ||
type: 'file', | ||
key: 'file', | ||
label: 'File', | ||
multiple: false, | ||
}; | ||
const variable = { | ||
...EMPTY_VARIABLE, | ||
source: 'component', | ||
key: 'file', | ||
dataType: 'array', | ||
}; | ||
|
||
const schema = asJsonSchema(variable, {[component.key]: component}); | ||
|
||
expect(schema).toEqual({ | ||
type: 'string', | ||
format: 'uri', | ||
}); | ||
}); | ||
|
||
test('JSON schema for multiple file uploads component', () => { | ||
const component = { | ||
type: 'file', | ||
key: 'file', | ||
label: 'File', | ||
multiple: true, | ||
}; | ||
const variable = { | ||
...EMPTY_VARIABLE, | ||
source: 'component', | ||
key: 'file', | ||
dataType: 'array', | ||
}; | ||
|
||
const schema = asJsonSchema(variable, {[component.key]: component}); | ||
|
||
expect(schema).toEqual({ | ||
type: 'array', | ||
items: { | ||
type: 'string', | ||
format: 'uri', | ||
}, | ||
}); | ||
}); | ||
|
||
test('JSON schema for map components', () => { | ||
const component = { | ||
type: 'map', | ||
key: 'map', | ||
label: 'Point coordinates', | ||
}; | ||
const variable = { | ||
...EMPTY_VARIABLE, | ||
source: 'component', | ||
key: 'map', | ||
dataType: 'array', | ||
}; | ||
|
||
const schema = asJsonSchema(variable, {[component.key]: component}); | ||
|
||
// we could be stricter, but we basically expect GeoJSON at the other end, which is | ||
// quite complex. | ||
expect(schema).toEqual({ | ||
type: 'object', | ||
properties: { | ||
type: { | ||
type: 'string', | ||
}, | ||
}, | ||
}); | ||
}); |