Browse Source

Up test

data-source-schema
Artur Arseniev 11 months ago
parent
commit
1952031ae4
  1. 10
      packages/core/src/data_sources/index.ts
  2. 6
      packages/core/test/specs/data_sources/index.ts

10
packages/core/src/data_sources/index.ts

@ -73,14 +73,14 @@ export default class DataSourceManager extends ItemManagerModule<ModuleConfig, D
}
/**
* Get value from data sources by key
* @param {String} key Path to value.
* @param {any} defValue
* Get value from data sources by path.
* @param {String} path Path to value.
* @param {any} defValue Default value if the path is not found.
* @returns {any}
* const value = dsm.getValue('ds_id.record_id.propName', 'defaultValue');
*/
getValue(key: string | string[], defValue: any) {
return get(this.getContext(), key, defValue);
getValue(path: string | string[], defValue?: any) {
return get(this.getContext(), path, defValue);
}
private getContext() {

6
packages/core/test/specs/data_sources/index.ts

@ -35,7 +35,7 @@ describe('DataSourceManager', () => {
em.on(dsm.events.add, eventAdd);
const ds = addDataSource();
expect(dsm.getAll().length).toBe(1);
expect(eventAdd).toBeCalledTimes(1);
expect(eventAdd).toHaveBeenCalledTimes(1);
expect(ds.getRecords().length).toBe(3);
});
@ -50,7 +50,7 @@ describe('DataSourceManager', () => {
const ds = addDataSource();
dsm.remove('ds1');
expect(dsm.getAll().length).toBe(0);
expect(event).toBeCalledTimes(1);
expect(event).toBeCalledWith(ds, expect.any(Object));
expect(event).toHaveBeenCalledTimes(1);
expect(event).toHaveBeenCalledWith(ds, expect.any(Object));
});
});

Loading…
Cancel
Save