From b78fcc59e831e3744cae8128a1ce0f8439009105 Mon Sep 17 00:00:00 2001 From: Alexey Nikipelau Date: Tue, 9 Apr 2024 18:28:42 +0300 Subject: [PATCH] add some tests --- src/process/filter/__tests__/filter.test.ts | 73 +++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/process/filter/__tests__/filter.test.ts diff --git a/src/process/filter/__tests__/filter.test.ts b/src/process/filter/__tests__/filter.test.ts new file mode 100644 index 00000000..65b0b017 --- /dev/null +++ b/src/process/filter/__tests__/filter.test.ts @@ -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}); +});