Skip to content

Commit

Permalink
FIO-8281: added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-formio committed May 14, 2024
1 parent b7c0405 commit 5a2c62c
Showing 1 changed file with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
simpleSelectOptions,
} from './fixtures/components';
import { generateProcessorContext } from './fixtures/util';
import { validateAvailableItems } from '../validateAvailableItems';
import { validateAvailableItems, validateAvailableItemsSync } from '../validateAvailableItems';

it('Validating a component without the available items validation parameter will return null', async () => {
const component = simpleTextField;
Expand Down Expand Up @@ -120,6 +120,43 @@ it('Validating a simple URL select component without the available items validat
expect(result).to.equal(null);
});

it('Validating a simple URL select component synchronously will return null', async () => {
const component: SelectComponent = {
...simpleSelectOptions,
dataSrc: 'url',
data: {
url: 'http://localhost:8080/numbers',
headers: [],
},
validate: { onlyAvailableItems: true },
};
const data = {
component: 'foo',
};
const context = generateProcessorContext(component, data);
const result = validateAvailableItemsSync(context);
expect(result).to.equal(null);
});

it('Validating a multiple URL select component synchronously will return null', async () => {
const component: SelectComponent = {
...simpleSelectOptions,
dataSrc: 'url',
data: {
url: 'http://localhost:8080/numbers',
headers: [],
},
multiple: true,
validate: { onlyAvailableItems: true },
};
const data = {
component: ['foo'],
};
const context = generateProcessorContext(component, data);
const result = validateAvailableItemsSync(context);
expect(result).to.equal(null);
});

it('Validating a simple JSON select component (string JSON) without the available items validation parameter will return null', async () => {
const component: SelectComponent = {
...simpleSelectOptions,
Expand Down

0 comments on commit 5a2c62c

Please sign in to comment.