Skip to content

Commit

Permalink
test(syringe): side option
Browse files Browse the repository at this point in the history
  • Loading branch information
BroKun committed Nov 14, 2024
1 parent 5ae7c4b commit 629100a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/mana-syringe/src/side-option.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import assert from 'assert';

import { register, GlobalContainer } from './container';
import { singleton } from './decorator';
import { registerSideOption } from './side-option';
Expand All @@ -16,4 +17,23 @@ describe('side option', () => {
const sideValue = GlobalContainer.get<boolean>('side');
assert(foo instanceof Foo && sideValue === true);
});

it('#class extend side option', () => {
const side = (name: string) => {
return (target: any) => {
Reflect.defineMetadata('name', name, target);
};
};
@side('Foo')
@singleton()
class Foo {}
register(Foo);

@side('FooBar')
@singleton()
class FooBar extends Foo {}
register(FooBar);

assert(Reflect.getMetadata('name', FooBar) === 'FooBar');
});
});

0 comments on commit 629100a

Please sign in to comment.