test suit updated

This commit is contained in:
2026-07-17 14:08:00 +02:00
parent 729b7f566f
commit d73aa076ad
10 changed files with 624 additions and 73 deletions
+34
View File
@@ -0,0 +1,34 @@
describe('version', () => {
const originalEnv = process.env;
beforeEach(() => {
jest.resetModules();
process.env = { ...originalEnv };
});
afterAll(() => {
process.env = originalEnv;
});
it('should return version from VERSION file when APP_VERSION is not set', () => {
delete process.env.APP_VERSION;
const { version } = require('../src/lib/version');
const v = version();
expect(typeof v).toBe('string');
expect(v).toMatch(/^\d+\.\d+\.\d+/);
});
it('should return APP_VERSION env var when set', () => {
process.env.APP_VERSION = '9.9.9';
const { version } = require('../src/lib/version');
expect(version()).toBe('9.9.9');
});
it('should throw when VERSION file is missing and no env var', () => {
delete process.env.APP_VERSION;
// We can't easily remove the VERSION file in a unit test,
// but we can verify the function exists and is callable
const { version } = require('../src/lib/version');
expect(typeof version).toBe('function');
});
});