From 5b2b60de1dae64fbcd75bc512439d6d24fe669cd Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 2 Mar 2024 09:49:20 +0400 Subject: [PATCH] Up --- src/dataSources/index.ts | 39 ++++++++++++++++++++++++++++----- test/specs/dataSources/index.ts | 18 ++++++++++++--- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/dataSources/index.ts b/src/dataSources/index.ts index bd33e73cb..e248c46ea 100644 --- a/src/dataSources/index.ts +++ b/src/dataSources/index.ts @@ -16,24 +16,40 @@ export default class DataSourceManager extends ItemManagerModule { acc[ds.id] = ds.records.reduce((accR, dr, i) => { diff --git a/test/specs/dataSources/index.ts b/test/specs/dataSources/index.ts index f0f1a6a53..eebe96dbb 100644 --- a/test/specs/dataSources/index.ts +++ b/test/specs/dataSources/index.ts @@ -48,9 +48,15 @@ describe('DataSourceManager', () => { expect(dsm.get(dsTest.id)).toBe(ds); }); - test.todo('remove DataSource'); - test.todo('update DataSource'); - test.todo('update DataSource record'); + test('remove DataSource', () => { + const event = jest.fn(); + em.on(dsm.events.remove, event); + const ds = addDataSource(); + dsm.remove('ds1'); + expect(dsm.getAll().length).toBe(0); + expect(event).toBeCalledTimes(1); + expect(event).toBeCalledWith(ds, expect.any(Object)); + }); describe('DataSource with DataVariable component', () => { let fixtures: HTMLElement; @@ -89,6 +95,12 @@ describe('DataSourceManager', () => { const cmpVar = addDataVariable(); expect(cmpVar.toHTML()).toBe('
Name1
'); }); + + test('component exports properly with variable', () => { + addDataSource(); + const cmpVar = addDataVariable(); + expect(cmpVar.getInnerHTML({ keepVariables: true })).toBe('ds1.id1.name'); + }); }); test('component is properly initiliazed with default value', () => {