-
Notifications
You must be signed in to change notification settings - Fork 6
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 #76 from formio/FIO-8177-fix-unsetting-empty-array…
…-values Fio 8177 fix unsetting empty array values
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { filterProcessSync } from '../'; | ||
import { generateProcessorContext } from '../../__tests__/fixtures/util'; | ||
|
||
it('Should not filter empty array value for dataGrid component', async () => { | ||
const dataGridComp = { | ||
type: 'datagrid', | ||
key: 'dataGrid', | ||
input: true, | ||
path: 'dataGrid', | ||
components: [ | ||
{ | ||
type: 'textfield', | ||
key: 'textField', | ||
input: true, | ||
label: 'Text Field' | ||
} | ||
] | ||
}; | ||
const data = { | ||
dataGrid: [] | ||
}; | ||
const context: any = generateProcessorContext(dataGridComp, data); | ||
filterProcessSync(context); | ||
expect(context.scope.filter).to.deep.equal({'dataGrid': true}); | ||
}); | ||
|
||
it('Should not filter empty array value for editGrid component', async () => { | ||
const editGridComp = { | ||
type: 'editgrid', | ||
key: 'editGrid', | ||
input: true, | ||
path: 'editGrid', | ||
components: [ | ||
{ | ||
type: 'textfield', | ||
key: 'textField', | ||
input: true, | ||
label: 'Text Field' | ||
} | ||
] | ||
}; | ||
const data = { | ||
editGrid: [] | ||
}; | ||
const context: any = generateProcessorContext(editGridComp, data); | ||
filterProcessSync(context); | ||
expect(context.scope.filter).to.deep.equal({'editGrid': true}); | ||
}); | ||
|
||
it('Should not filter empty array value for datTable component', async () => { | ||
const dataTableComp = { | ||
type: 'datatable', | ||
key: 'dataTable', | ||
input: true, | ||
path: 'dataTable', | ||
components: [ | ||
{ | ||
type: 'textfield', | ||
key: 'textField', | ||
input: true, | ||
label: 'Text Field' | ||
} | ||
] | ||
}; | ||
const data = { | ||
dataTable: [] | ||
}; | ||
const context: any = generateProcessorContext(dataTableComp, data); | ||
filterProcessSync(context); | ||
expect(context.scope.filter).to.deep.equal({'dataTable': true}); | ||
}); |
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