- Switch from deprecated Vue CLI plugin to `electron-vite` (see nklayman/vue-cli-plugin-electron-builder#1982) - Update main/preload scripts to use `index.cjs` filenames to support `"type": "module"`, resolving crash issue (#233). This crash was related to Electron not supporting ESM (see electron/asar#249, electron/electron#21457). - This commit completes migration to Vite from Vue CLI (#230). Structure changes: - Introduce separate folders for Electron's main and preload processes. - Move TypeHelpers to `src/` to mark tit as accessible by the rest of the code. Config changes: - Make `vite.config.ts` reusable by Electron configuration. - On electron-builder, use `--publish` flag instead of `-p` for clarity. Tests: - Add log for preload script loading verification. - Implement runtime environment sanity checks. - Enhance logging in `check-desktop-runtime-errors`.
24 lines
612 B
TypeScript
24 lines
612 B
TypeScript
import { it, expect } from 'vitest';
|
|
import { Constructible } from '@/TypeHelpers';
|
|
|
|
interface ISingletonTestData<T> {
|
|
getter: () => T;
|
|
expectedType: Constructible<T>;
|
|
}
|
|
|
|
export function itIsSingleton<T>(test: ISingletonTestData<T>): void {
|
|
it('gets the expected type', () => {
|
|
// act
|
|
const instance = test.getter();
|
|
// assert
|
|
expect(instance).to.be.instanceOf(test.expectedType);
|
|
});
|
|
it('multiple calls get the same instance', () => {
|
|
// act
|
|
const instance1 = test.getter();
|
|
const instance2 = test.getter();
|
|
// assert
|
|
expect(instance1).to.equal(instance2);
|
|
});
|
|
}
|