Skip to content

Commit df6aaea

Browse files
committed
chore: test
Signed-off-by: dhmlau <dhmlau@ca.ibm.com>
1 parent 8ebf95b commit df6aaea

4 files changed

Lines changed: 0 additions & 174 deletions

File tree

packages/core/src/__tests__/unit/extension-point.unit.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -573,17 +573,6 @@ describe('Extension Point', () => {
573573
expect(binding.key).to.equal('extensions.custom-name');
574574
});
575575

576-
it('adds extension with default key', () => {
577-
@injectable()
578-
class MyExtension {
579-
value = 'extension';
580-
}
581-
582-
const binding = addExtension(ctx, 'my-extension-point', MyExtension);
583-
584-
expect(binding.key).to.match(/^MyExtension/);
585-
});
586-
587576
it('returns the created binding', () => {
588577
@injectable()
589578
class MyExtension {}
@@ -596,52 +585,6 @@ describe('Extension Point', () => {
596585
});
597586

598587
describe('Integration scenarios', () => {
599-
it('extension point with multiple extensions', async () => {
600-
interface Plugin {
601-
name: string;
602-
execute(): string;
603-
}
604-
605-
@extensionPoint('plugins')
606-
class PluginManager {
607-
constructor(
608-
@extensions()
609-
public getPlugins: Getter<Plugin[]>,
610-
) {}
611-
612-
async executeAll(): Promise<string[]> {
613-
const plugins = await this.getPlugins();
614-
return plugins.map(p => p.execute());
615-
}
616-
}
617-
618-
@injectable({tags: {[CoreTags.EXTENSION_FOR]: 'plugins'}})
619-
class PluginA implements Plugin {
620-
name = 'A';
621-
execute() {
622-
return 'Result A';
623-
}
624-
}
625-
626-
@injectable({tags: {[CoreTags.EXTENSION_FOR]: 'plugins'}})
627-
class PluginB implements Plugin {
628-
name = 'B';
629-
execute() {
630-
return 'Result B';
631-
}
632-
}
633-
634-
ctx.bind('plugin.manager').toClass(PluginManager);
635-
ctx.bind('plugin.a').toClass(PluginA);
636-
ctx.bind('plugin.b').toClass(PluginB);
637-
638-
const manager = await ctx.get<PluginManager>('plugin.manager');
639-
const results = await manager.executeAll();
640-
expect(results).to.have.length(2);
641-
expect(results).to.containEql('Result A');
642-
expect(results).to.containEql('Result B');
643-
});
644-
645588
it('extension contributing to multiple extension points', () => {
646589
@injectable()
647590
class MultiExtension {}

packages/core/src/__tests__/unit/lifecycle.unit.ts

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,6 @@ describe('LifeCycle', () => {
110110
const instance = new MyObserver();
111111
expect(isLifeCycleObserver(instance)).to.be.true();
112112
});
113-
114-
it('returns false for null', () => {
115-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
116-
expect(isLifeCycleObserver(null as any)).to.be.false();
117-
});
118-
119-
it('returns false for undefined', () => {
120-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
121-
expect(isLifeCycleObserver(undefined as any)).to.be.false();
122-
});
123113
});
124114

125115
describe('isLifeCycleObserverClass', () => {
@@ -181,13 +171,6 @@ describe('LifeCycle', () => {
181171
class DerivedObserver extends BaseObserver {}
182172
expect(isLifeCycleObserverClass(DerivedObserver)).to.be.true();
183173
});
184-
185-
it('returns false for class with non-prototype', () => {
186-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
187-
const NotAClass = function () {} as any;
188-
NotAClass.prototype = undefined;
189-
expect(isLifeCycleObserverClass(NotAClass)).to.be.false();
190-
});
191174
});
192175

193176
describe('asLifeCycleObserver', () => {
@@ -277,78 +260,6 @@ describe('LifeCycle', () => {
277260
});
278261

279262
describe('@lifeCycleObserver decorator', () => {
280-
it('decorates class as life cycle observer', () => {
281-
@lifeCycleObserver()
282-
class MyObserver implements LifeCycleObserver {
283-
async start() {}
284-
}
285-
286-
const ctx = new Context();
287-
ctx.bind('my.observer').toClass(MyObserver);
288-
const binding = ctx.getBinding('my.observer');
289-
expect(Array.from(binding.tagNames)).to.containEql(
290-
CoreTags.LIFE_CYCLE_OBSERVER,
291-
);
292-
});
293-
294-
it('decorates class with group name', () => {
295-
@lifeCycleObserver('my-group')
296-
class MyObserver implements LifeCycleObserver {
297-
async start() {}
298-
}
299-
300-
const ctx = new Context();
301-
ctx.bind('my.observer').toClass(MyObserver);
302-
const binding = ctx.getBinding('my.observer');
303-
expect(binding.tagMap[CoreTags.LIFE_CYCLE_OBSERVER_GROUP]).to.equal(
304-
'my-group',
305-
);
306-
});
307-
308-
it('decorates class with empty group name', () => {
309-
@lifeCycleObserver('')
310-
class MyObserver implements LifeCycleObserver {
311-
async start() {}
312-
}
313-
314-
const ctx = new Context();
315-
ctx.bind('my.observer').toClass(MyObserver);
316-
const binding = ctx.getBinding('my.observer');
317-
expect(binding.tagMap[CoreTags.LIFE_CYCLE_OBSERVER_GROUP]).to.equal('');
318-
});
319-
320-
it('decorates class with additional binding specs', () => {
321-
@lifeCycleObserver('my-group', {scope: BindingScope.SINGLETON})
322-
class MyObserver implements LifeCycleObserver {
323-
async start() {}
324-
}
325-
326-
const ctx = new Context();
327-
ctx.bind('my.observer').toClass(MyObserver);
328-
const binding = ctx.getBinding('my.observer');
329-
expect(binding.scope).to.equal(BindingScope.SINGLETON);
330-
expect(binding.tagMap[CoreTags.LIFE_CYCLE_OBSERVER_GROUP]).to.equal(
331-
'my-group',
332-
);
333-
});
334-
335-
it('decorates class with multiple binding specs', () => {
336-
@lifeCycleObserver(
337-
'my-group',
338-
{scope: BindingScope.SINGLETON},
339-
{tags: ['custom-tag']},
340-
)
341-
class MyObserver implements LifeCycleObserver {
342-
async start() {}
343-
}
344-
345-
const ctx = new Context();
346-
ctx.bind('my.observer').toClass(MyObserver);
347-
const binding = ctx.getBinding('my.observer');
348-
expect(binding.scope).to.equal(BindingScope.SINGLETON);
349-
expect(Array.from(binding.tagNames)).to.containEql('custom-tag');
350-
});
351-
352263
it('works with @injectable decorator', () => {
353264
@lifeCycleObserver('my-group')
354265
@injectable({scope: BindingScope.SINGLETON})

packages/core/src/__tests__/unit/service.unit.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,21 +288,6 @@ describe('Service', () => {
288288
});
289289

290290
describe('filterByServiceInterface', () => {
291-
it('filters by service class', () => {
292-
@injectable()
293-
class MyService {}
294-
295-
const binding1 = Binding.bind('service1')
296-
.toClass(MyService)
297-
.apply(asService(MyService));
298-
const binding2 = Binding.bind('service2').toClass(MyService);
299-
300-
const filter = filterByServiceInterface(MyService);
301-
302-
expect(filter(binding1)).to.be.true();
303-
expect(filter(binding2)).to.be.false();
304-
});
305-
306291
it('filters by string interface', () => {
307292
@injectable()
308293
class MyService {}

packages/filter/src/__tests__/unit/query.unit.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,6 @@ describe('FilterBuilder - Unit Tests', () => {
662662
});
663663

664664
describe('impose', () => {
665-
it('imposes a filter on empty builder', () => {
666-
const builder = new FilterBuilder();
667-
builder.impose({where: {name: 'John'}, limit: 10});
668-
expect(builder.build()).to.eql({where: {name: 'John'}, limit: 10});
669-
});
670-
671665
it('imposes a where object as filter', () => {
672666
const builder = new FilterBuilder();
673667
builder.impose({name: 'John', age: 30});
@@ -830,13 +824,6 @@ describe('isFilter', () => {
830824
).to.be.true();
831825
});
832826

833-
it('returns false for non-object', () => {
834-
expect(isFilter('not an object')).to.be.false();
835-
expect(isFilter(123)).to.be.false();
836-
expect(isFilter(null)).to.be.false();
837-
expect(isFilter(undefined)).to.be.false();
838-
});
839-
840827
it('returns false for object with invalid fields', () => {
841828
expect(isFilter({where: {}, invalidField: 'value'})).to.be.false();
842829
});

0 commit comments

Comments
 (0)