Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyNikipelau committed Apr 9, 2024
1 parent a979d06 commit b78fcc5
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/process/filter/__tests__/filter.test.ts
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});
});

0 comments on commit b78fcc5

Please sign in to comment.