Skip to content
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

FIO-8639 fixed validation for select component if onlyAvailableItems is set to false #118

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,27 @@ it('Validating a simple static values select component with the available items
expect(result).to.equal(null);
});

it('Validating a simple static values select component with the available items validation parameter set to false will return null', async () => {

const component: SelectComponent = {
...simpleSelectOptions,
dataSrc: 'values',
data: {
values: [
{ label: 'foo', value: 'foo' },
{ label: 'bar', value: 'bar' }
],
},
validate: { onlyAvailableItems: false },
};
const data = {
component: 'baz',
};
const context = generateProcessorContext(component, data);
const result = await validateAvailableItems(context);
expect(result).to.equal(null);
});

it('Validating a simple URL select component without the available items validation parameter will return null', async () => {
const component: SelectComponent = {
...simpleSelectOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/process/validation/rules/validateAvailableItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function isValidatableRadioComponent(component: any): component is RadioComponen
function isValidateableSelectComponent(component: any): component is SelectComponent {
return (
component &&
!!component.validate?.hasOwnProperty('onlyAvailableItems') &&
!!component.validate?.onlyAvailableItems &&
component.type === 'select' &&
component.dataSrc !== 'resource'
);
Expand Down
Loading