diff --git a/packages/core/test/specs/data_sources/index.ts b/packages/core/test/specs/data_sources/index.ts index cbc1d53c8..3549df1a4 100644 --- a/packages/core/test/specs/data_sources/index.ts +++ b/packages/core/test/specs/data_sources/index.ts @@ -1,5 +1,5 @@ import DataSourceManager from '../../../src/data_sources'; -import { DataSourceProps } from '../../../src/data_sources/types'; +import { DataSourceProps, DataFieldPrimitiveType } from '../../../src/data_sources/types'; import { setupTestEditor } from '../../common'; import EditorModel from '../../../src/editor/model/Editor'; @@ -53,4 +53,15 @@ describe('DataSourceManager', () => { expect(event).toHaveBeenCalledTimes(1); expect(event).toHaveBeenCalledWith(ds, expect.any(Object)); }); + + test('getValue', () => { + const ds = addDataSource(); + const testPath = ds.getRecord('id2')?.getPath('name') || ''; + expect(dsm.getValue(`${ds.id}.id1.name`)).toBe('Name1'); + expect(dsm.getValue(testPath)).toBe('Name2'); + expect(dsm.getValue(`${ds.id}.non-existing.name`)).toBeUndefined(); + expect(dsm.getValue(`${ds.id}.non-existing.name`, 'Default name')).toBe('Default name'); + expect(dsm.getValue(`${ds.id}.id1.nonExisting`)).toBeUndefined(); + expect(dsm.getValue('non-existing-ds.id1.name')).toBeUndefined(); + }); });