chore(test): make DIContainer tolerant to missing electron.app for vitest

This commit is contained in:
2025-11-26 17:17:02 +01:00
parent fef75008d8
commit b6b8303f38
2 changed files with 110 additions and 19 deletions

View File

@@ -0,0 +1,21 @@
import { describe, it, expect } from 'vitest';
import { DIContainer, resolveTemplatePath, resolveSessionDataPath } from '../../apps/companion/main/di-container';
describe('DIContainer (smoke) - test-tolerance', () => {
it('constructs without electron.app and exposes path resolvers', () => {
// Constructing DIContainer should not throw in plain Node (vitest) environment.
expect(() => {
// Note: getInstance lazily constructs the container
DIContainer.resetInstance();
DIContainer.getInstance();
}).not.toThrow();
// Path resolvers should return strings
const tpl = resolveTemplatePath();
const sess = resolveSessionDataPath();
expect(typeof tpl).toBe('string');
expect(tpl.length).toBeGreaterThan(0);
expect(typeof sess).toBe('string');
expect(sess.length).toBeGreaterThan(0);
});
});