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.
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { describe } from 'vitest';
|
|
import type { ISanityCheckOptions } from '@/infrastructure/RuntimeSanity/Common/ISanityCheckOptions';
|
|
import { validateRuntimeSanity } from '@/infrastructure/RuntimeSanity/SanityChecks';
|
|
import { isBoolean } from '@/TypeHelpers';
|
|
|
|
describe('SanityChecks', () => {
|
|
describe('validateRuntimeSanity', () => {
|
|
describe('does not throw on current environment', () => {
|
|
// arrange
|
|
const testOptions = generateTestOptions();
|
|
testOptions.forEach((options) => {
|
|
it(`options: ${JSON.stringify(options)}`, () => {
|
|
// act
|
|
const act = () => validateRuntimeSanity(options);
|
|
|
|
// assert
|
|
expect(act).to.not.throw();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
function generateTestOptions(): ISanityCheckOptions[] {
|
|
const defaultOptions: ISanityCheckOptions = {
|
|
validateEnvironmentVariables: true,
|
|
validateWindowVariables: true,
|
|
};
|
|
return generateBooleanPermutations(defaultOptions);
|
|
}
|
|
|
|
function generateBooleanPermutations<T>(object: T | undefined): T[] {
|
|
if (!object) {
|
|
return [];
|
|
}
|
|
|
|
const keys = Object.keys(object) as (keyof T)[];
|
|
|
|
if (keys.length === 0) {
|
|
return [object];
|
|
}
|
|
|
|
const currentKey = keys[0];
|
|
const currentValue = object[currentKey];
|
|
|
|
if (!isBoolean(currentValue)) {
|
|
return generateBooleanPermutations({
|
|
...object,
|
|
[currentKey]: currentValue,
|
|
});
|
|
}
|
|
|
|
const remainingKeys = Object.fromEntries(
|
|
keys.slice(1).map((key) => [key, object[key]]),
|
|
) as unknown as T | undefined;
|
|
|
|
const subPermutations = generateBooleanPermutations(remainingKeys);
|
|
|
|
return [
|
|
...subPermutations.map((p) => ({ ...p, [currentKey]: true })),
|
|
...subPermutations.map((p) => ({ ...p, [currentKey]: false })),
|
|
];
|
|
}
|