Updated unit tests
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-12-21 10:37:29 +01:00
parent 76ec1fceae
commit 9790f0cdb1
1 changed files with 39 additions and 0 deletions

View File

@ -80,6 +80,45 @@ describe('Component smartTable', () => {
});
});
describe('defaultOrder', () => {
it('should insert a new object to the controller sortCriteria with a sortType value of "ASC"', () => {
const element = document.createElement('div');
controller.model = {order: 'id'};
controller.columns = [
{field: 'id', element: element},
{field: 'test1', element: element},
{field: 'test2', element: element}
];
controller.defaultOrder();
const firstSortCriteria = controller.sortCriteria[0];
expect(firstSortCriteria.field).toEqual('id');
expect(firstSortCriteria.sortType).toEqual('ASC');
});
it('should insert two new objects to the controller sortCriteria with a sortType values of "ASC" and "DESC"', () => {
const element = document.createElement('div');
controller.model = {order: 'test1, id DESC'};
controller.columns = [
{field: 'id', element: element},
{field: 'test1', element: element},
{field: 'test2', element: element}
];
controller.defaultOrder();
const firstSortCriteria = controller.sortCriteria[0];
const secondSortCriteria = controller.sortCriteria[1];
expect(firstSortCriteria.field).toEqual('test1');
expect(firstSortCriteria.sortType).toEqual('ASC');
expect(secondSortCriteria.field).toEqual('id');
expect(secondSortCriteria.sortType).toEqual('DESC');
});
});
describe('addFilter()', () => {
it('should call the model addFilter() with a basic where filter if exprBuilder() was not received', () => {
controller.model = {addFilter: jest.fn()};