This commit upgrades TypeScript to the latest version 5.3 and introduces `verbatimModuleSyntax` in line with the official Vue guide recommendatinos (vuejs/docs#2592). By enforcing `import type` for type-only imports, this commit improves code clarity and supports tooling optimization, ensuring imports are only bundled when necessary for runtime. Changes: - Bump TypeScript to 5.3.3 across the project. - Adjust import statements to utilize `import type` where applicable, promoting cleaner and more efficient code.
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { it, describe, expect } from 'vitest';
|
|
import { shallowMount } from '@vue/test-utils';
|
|
import { defineComponent, inject } from 'vue';
|
|
import { type InjectionKeySelector, InjectionKeys, injectKey } from '@/presentation/injectionSymbols';
|
|
import { provideDependencies } from '@/presentation/bootstrapping/DependencyProvider';
|
|
import { buildContext } from '@/application/Context/ApplicationContextFactory';
|
|
import type { IApplicationContext } from '@/application/Context/IApplicationContext';
|
|
|
|
describe('DependencyResolution', () => {
|
|
describe('all dependencies can be injected', async () => {
|
|
// arrange
|
|
const context = await buildContext();
|
|
const dependencies = collectProvidedKeys(context);
|
|
Object.values(InjectionKeys).forEach((key) => {
|
|
it(`"${key.key.description}"`, () => {
|
|
// act
|
|
const resolvedDependency = resolve(() => key, dependencies);
|
|
// assert
|
|
expect(resolvedDependency).to.toBeDefined();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
type ProvidedKeys = Record<symbol, unknown>;
|
|
|
|
function collectProvidedKeys(context: IApplicationContext): ProvidedKeys {
|
|
const providedKeys: ProvidedKeys = {};
|
|
provideDependencies(context, {
|
|
inject,
|
|
provide: (key, value) => {
|
|
providedKeys[key as symbol] = value;
|
|
},
|
|
});
|
|
return providedKeys;
|
|
}
|
|
|
|
function resolve<T>(
|
|
selector: InjectionKeySelector<T>,
|
|
providedKeys: ProvidedKeys,
|
|
): T | undefined {
|
|
let injectedDependency: T | undefined;
|
|
shallowMount(defineComponent({
|
|
setup() {
|
|
injectedDependency = injectKey(selector);
|
|
},
|
|
}), {
|
|
global: {
|
|
provide: providedKeys,
|
|
},
|
|
});
|
|
return injectedDependency;
|
|
}
|