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-8848 fixed validation for TextArea with Save as Json #138

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
21 changes: 18 additions & 3 deletions src/process/validation/rules/__tests__/validateMultiple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('validateMultiple', () => {
expect(isEligible(component)).to.be.true;
});

it('should return false for textArea component with as !== json', () => {
it('should return false for textArea component with as !== json if multiple', () => {
const component: TextAreaComponent = {
type: 'textarea',
as: 'text',
Expand All @@ -50,9 +50,9 @@ describe('validateMultiple', () => {
expect(isEligible(component)).to.be.false;
});

it('should return true for textArea component with as === json', () => {
it('should return true for textArea component with as === json if multiple', () => {
const component: TextAreaComponent = {
type: 'textArea',
type: 'textarea',
as: 'json',
input: true,
key: 'textAreaJson',
Expand All @@ -66,6 +66,21 @@ describe('validateMultiple', () => {
expect(isEligible(component)).to.be.true;
});

it('should return false for textArea component with as === json if not multiple', () => {
const component: TextAreaComponent = {
type: 'textarea',
as: 'json',
input: true,
key: 'textAreaJson',
rows: 4,
wysiwyg: true,
editor: 'ace',
fixedSize: true,
inputFormat: 'plain',
};
expect(isEligible(component)).to.be.false;
});

it('should return true for other component types', () => {
const component: Component = {
type: 'textfield',
Expand Down
3 changes: 2 additions & 1 deletion src/process/validation/rules/validateMultiple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const isEligible = (component: Component) => {
case 'textarea':
if (
!(component as TextAreaComponent).as ||
(component as TextAreaComponent).as !== 'json'
(component as TextAreaComponent).as !== 'json' ||
((component as TextAreaComponent).as === 'json' && !component.multiple)
) {
return false;
}
Expand Down
Loading