From af099a25d6ccba1ffbbff4582033ea924d013d66 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Tue, 11 Mar 2025 17:44:03 +0100 Subject: [PATCH] tests: add mode parameter to RegisterInstanceDecorator - Introduced a `mode` parameter to the `test_RegisterInstanceDecorator` function allowing 'instance' or 'standalone' modes. - Updated test cases to utilize the new `mode` parameter when registering an instance. - Disabled specific ESLint rule in `Decorators.test.ts` for deprecation warnings. - Added an additional test call to `test_RegisterInstanceDecorator` with 'instance' mode. --- src/__tests__/Decorators.spec.ts | 11 +++++++++-- src/__tests__/Decorators.test.ts | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/__tests__/Decorators.spec.ts b/src/__tests__/Decorators.spec.ts index b3c6cdc..df90bf3 100644 --- a/src/__tests__/Decorators.spec.ts +++ b/src/__tests__/Decorators.spec.ts @@ -282,6 +282,7 @@ export function test_RegisterInstanceDecorator( Container: ITSinjex_, // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type registerInstance: Function, + mode: 'instance' | 'standalone' = 'standalone', ): void { describe('RegisterInstance Decorator Tests', () => { let container: ITSinjex; @@ -295,7 +296,10 @@ export function test_RegisterInstanceDecorator( }); it('should register an instance of a dependency', () => { - @registerInstance('InstanceIdentifier') + @registerInstance( + 'InstanceIdentifier', + mode === 'instance' ? 'instance' : undefined, + ) class TestClass { private readonly _dependency!: any; @@ -337,7 +341,10 @@ export function test_RegisterInstanceDecorator( }); it('should register an instance of a dependency and get it on set', () => { - @registerInstance('InstanceIdentifier') + @registerInstance( + 'InstanceIdentifier', + mode === 'instance' ? 'instance' : undefined, + ) class TestClass { private readonly _dependency!: any; diff --git a/src/__tests__/Decorators.test.ts b/src/__tests__/Decorators.test.ts index efba3e6..28d2d54 100644 --- a/src/__tests__/Decorators.test.ts +++ b/src/__tests__/Decorators.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable deprecation/deprecation */ import { TSinjex } from 'src/classes/TSinjex'; import { Inject } from 'src/decorators/Inject'; import { Register } from 'src/decorators/Register'; @@ -13,3 +14,5 @@ test_InjectDecorator(TSinjex, Inject); test_RegisterDecorator(TSinjex, Register); test_RegisterInstanceDecorator(TSinjex, RegisterInstance); + +test_RegisterInstanceDecorator(TSinjex, Register, 'instance');