Skip to content

Commit

Permalink
FIO-8639 fixed validation for select component if onlyAvailableItems …
Browse files Browse the repository at this point in the history
…is set to false
  • Loading branch information
HannaKurban committed Jul 17, 2024
1 parent e7fda88 commit 63c6bb7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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 without the available items validation parameter 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

0 comments on commit 63c6bb7

Please sign in to comment.