### Raise Coverage and Enhance Testing
Increased coverage thresholds to 90% across all metrics. Added exclusions for `.spec.ts` and `.test.ts` files to the coverage configuration. Introduced new test files for `Decorators` and `Functions`, incorporating detailed unit tests for decorators and DI functionalities. Removed outdated and redundant test files, consolidating their functionality into the updated tests. Also added new npm script for jest watch mode. Marked helper and main index files to be ignored by the coverage.
This commit is contained in:
70
src/__tests__/Functions.spec.ts
Normal file
70
src/__tests__/Functions.spec.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { ITSinjex, ITSinjex_ } from 'src/interfaces/ITSinjex';
|
||||
|
||||
export function test_RegisterFunction(
|
||||
Container: ITSinjex_,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
register: Function,
|
||||
): void {
|
||||
describe('Register Function Tests', () => {
|
||||
let container: ITSinjex;
|
||||
|
||||
beforeEach(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(Container as any)['_instance'] = undefined;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(Container as any)['_dependencies'] = undefined;
|
||||
container = Container.getInstance();
|
||||
});
|
||||
|
||||
it('should register a dependency', () => {
|
||||
const identifier = 'MockDependencyIdentifier';
|
||||
class TestClass {
|
||||
private readonly _dependency!: any;
|
||||
|
||||
public getDependency() {
|
||||
return this._dependency;
|
||||
}
|
||||
}
|
||||
|
||||
register(identifier, TestClass, false);
|
||||
|
||||
const resolvedDependency = container.resolve(identifier);
|
||||
expect(resolvedDependency).toBe(TestClass);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function test_ResolveFunction(
|
||||
Container: ITSinjex_,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
resolve: Function,
|
||||
): void {
|
||||
describe('Resolve Function Tests', () => {
|
||||
let container: ITSinjex;
|
||||
|
||||
beforeEach(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(Container as any)['_instance'] = undefined;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(Container as any)['_dependencies'] = undefined;
|
||||
container = Container.getInstance();
|
||||
});
|
||||
|
||||
it('should resolve a dependency', () => {
|
||||
const identifier = 'MockDependencyIdentifier';
|
||||
class TestClass {
|
||||
private readonly _dependency!: any;
|
||||
|
||||
public getDependency() {
|
||||
return this._dependency;
|
||||
}
|
||||
}
|
||||
|
||||
container.register(identifier, TestClass);
|
||||
|
||||
const resolvedDependency = resolve(identifier);
|
||||
expect(resolvedDependency).toBe(TestClass);
|
||||
});
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user