Rename DIContainer to TSInjex and refactor interfaces
- Renamed DIContainer class and related references to TSInjex to better indicate its purpose as a TypeScript-based dependency injection container. - Extracted IDependency interface to a separate file to improve modularity. - Split the ITSInjex interface into ITSInjexRegister and ITSInjexResolve, then extended them in a new ITSInjex interface to clarify the separation of concerns. - Updated tests and decorators to reflect the renaming and interface changes. - Adjusted helper, functions, and index export to align with the new TSInjex structure.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { test_IDIContainer } from './IDIContainer.spec';
|
||||
import { DIContainer } from '../DIContainer';
|
||||
import { TSInjex } from '../TSInjex';
|
||||
|
||||
test_IDIContainer(DIContainer);
|
||||
test_IDIContainer(TSInjex);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { ITSInjex_, ITSInjex } from '../interfaces/IDIContainer';
|
||||
import { ITSInjex_, ITSInjex } from '../interfaces/ITSInjex';
|
||||
|
||||
/**
|
||||
* Test the implementation of a DIContainer
|
||||
@@ -24,10 +24,21 @@ export function test_IDIContainer(Container: ITSInjex_): void {
|
||||
expect(resolvedDependency).toBe(dependency);
|
||||
});
|
||||
|
||||
it('should throw an error when resolving a non-registered dependency', () => {
|
||||
it('should register and resolve a dependency static', () => {
|
||||
const identifier = 'myDependency';
|
||||
const dependency = { value: 42 };
|
||||
|
||||
Container.register(identifier, dependency);
|
||||
|
||||
const resolvedDependency =
|
||||
Container.resolve<typeof dependency>(identifier);
|
||||
expect(resolvedDependency).toBe(dependency);
|
||||
});
|
||||
|
||||
it('should throw an error when resolving a non-registered dependency static', () => {
|
||||
const identifier = 'nonExistentDependency';
|
||||
|
||||
expect(() => container.resolve<unknown>(identifier)).toThrow();
|
||||
expect(() => Container.resolve<unknown>(identifier)).toThrow();
|
||||
});
|
||||
|
||||
// Add more tests as necessary
|
||||
|
Reference in New Issue
Block a user