chore(util-registry): fix tests
This commit is contained in:
parent
86dd3a96d2
commit
ea5351e483
@ -55,7 +55,7 @@ export class UtilRegistry {
|
|||||||
|
|
||||||
setupInstances
|
setupInstances
|
||||||
.filter((instance) => instance && typeof instance.start === 'function')
|
.filter((instance) => instance && typeof instance.start === 'function')
|
||||||
.forEach((instance) => this.start(instance));
|
.forEach((instance) => instance.start());
|
||||||
|
|
||||||
if (DEBUG_MODE > 1) {
|
if (DEBUG_MODE > 1) {
|
||||||
console.info('initialized js util instances:');
|
console.info('initialized js util instances:');
|
||||||
@ -100,10 +100,6 @@ export class UtilRegistry {
|
|||||||
return instances.map((instance) => ({ scope: scope, util: util, ...instance }));
|
return instances.map((instance) => ({ scope: scope, util: util, ...instance }));
|
||||||
}
|
}
|
||||||
|
|
||||||
start(instance) {
|
|
||||||
instance.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
find(name) {
|
find(name) {
|
||||||
return this._registeredUtils.find((util) => util.name === name);
|
return this._registeredUtils.find((util) => util.name === name);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -153,18 +153,20 @@ describe('UtilRegistry', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should start instances that provide a start function', () => {
|
it('should start instances that provide a start function', () => {
|
||||||
spyOn(utilRegistry, 'start');
|
|
||||||
utilRegistry.register(TestUtil3);
|
utilRegistry.register(TestUtil3);
|
||||||
utilRegistry.initAll(testScope);
|
const initializedInstances = utilRegistry.initAll(testScope);
|
||||||
expect(utilRegistry.start.calls.count()).toBe(2);
|
|
||||||
|
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', () => {
|
it('should not start instances that do not provide a start function', () => {
|
||||||
spyOn(utilRegistry, 'start');
|
|
||||||
utilRegistry.register(TestUtil1);
|
utilRegistry.register(TestUtil1);
|
||||||
utilRegistry.register(TestUtil2);
|
utilRegistry.register(TestUtil2);
|
||||||
utilRegistry.initAll(testScope);
|
const initializedInstances = utilRegistry.initAll(testScope);
|
||||||
expect(utilRegistry.start).not.toHaveBeenCalled();
|
|
||||||
|
expect(initializedInstances.length).toBe(2);
|
||||||
|
expect(initializedInstances.map((instance) => instance.util)).toEqual([TestUtil1,TestUtil2]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user