From ea5351e4833697ab0ce048e3067b0caf7fb77b5a Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Wed, 4 Dec 2019 14:59:44 +0100 Subject: [PATCH] chore(util-registry): fix tests --- .../src/services/util-registry/util-registry.js | 6 +----- .../services/util-registry/util-registry.spec.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/frontend/src/services/util-registry/util-registry.js b/frontend/src/services/util-registry/util-registry.js index 8638c947d..24251414e 100644 --- a/frontend/src/services/util-registry/util-registry.js +++ b/frontend/src/services/util-registry/util-registry.js @@ -55,7 +55,7 @@ export class UtilRegistry { setupInstances .filter((instance) => instance && typeof instance.start === 'function') - .forEach((instance) => this.start(instance)); + .forEach((instance) => instance.start()); if (DEBUG_MODE > 1) { console.info('initialized js util instances:'); @@ -100,10 +100,6 @@ export class UtilRegistry { return instances.map((instance) => ({ scope: scope, util: util, ...instance })); } - start(instance) { - instance.start(); - } - find(name) { return this._registeredUtils.find((util) => util.name === name); } diff --git a/frontend/src/services/util-registry/util-registry.spec.js b/frontend/src/services/util-registry/util-registry.spec.js index 087ec0817..cb9ef95b7 100644 --- a/frontend/src/services/util-registry/util-registry.spec.js +++ b/frontend/src/services/util-registry/util-registry.spec.js @@ -153,18 +153,20 @@ describe('UtilRegistry', () => { }); it('should start instances that provide a start function', () => { - spyOn(utilRegistry, 'start'); utilRegistry.register(TestUtil3); - utilRegistry.initAll(testScope); - expect(utilRegistry.start.calls.count()).toBe(2); + const initializedInstances = utilRegistry.initAll(testScope); + + expect(initializedInstances.length).toBe(2); + expect(initializedInstances.map((instance) => instance.util)).toEqual([TestUtil3,TestUtil3]); }); it('should not start instances that do not provide a start function', () => { - spyOn(utilRegistry, 'start'); utilRegistry.register(TestUtil1); utilRegistry.register(TestUtil2); - utilRegistry.initAll(testScope); - expect(utilRegistry.start).not.toHaveBeenCalled(); + const initializedInstances = utilRegistry.initAll(testScope); + + expect(initializedInstances.length).toBe(2); + expect(initializedInstances.map((instance) => instance.util)).toEqual([TestUtil1,TestUtil2]); }); }); });