feat: Add basic Datatable and Pagination components (#5652)

* feat: add Datatable component

* feat: migrate to n8n-pagination and add datatable tests

* chore: fix linting issue
This commit is contained in:
Alex Grozav
2023-03-15 18:52:02 +02:00
committed by GitHub
parent b4e60c3b47
commit 29f2629716
16 changed files with 523 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
import { getValueByPath } from '@/utils';
describe('getValueByPath()', () => {
const object = {
id: '1',
name: 'Richard Hendricks',
address: {
city: 'Palo Alto',
state: 'California',
country: 'United States',
},
};
it('should return direct field from object', () => {
const path = 'name';
expect(getValueByPath(object, path)).toEqual(object.name);
});
it('should return nested field from object', () => {
const path = 'address.country';
expect(getValueByPath(object, path)).toEqual(object.address.country);
});
it('should return undefined if direct field does not exist', () => {
const path = 'other';
expect(getValueByPath(object, path)).toEqual(undefined);
});
it('should return undefined if nested field does not exist', () => {
const path = 'address.other';
expect(getValueByPath(object, path)).toEqual(undefined);
});
it('should return undefined if path does not exist', () => {
const path = 'other.other';
expect(getValueByPath(object, path)).toEqual(undefined);
});
});