version-generation.test.tsโข2.11 kB
import { describe, it, expect } from '@jest/globals';
import * as fs from 'fs/promises';
import * as path from 'path';
describe('Version Generation', () => {
describe('generated version file', () => {
it('should check if version generation script exists', async () => {
const scriptPath = path.join(process.cwd(), 'scripts', 'generate-version.js');
const exists = await fs.access(scriptPath).then(() => true).catch(() => false);
expect(exists).toBe(true);
});
it('should verify expected version constants format', () => {
// Test the expected format of generated constants
const testVersion = '1.4.1';
const testTimestamp = new Date().toISOString();
const testPackageName = '@dollhousemcp/mcp-server';
// Verify format is valid TypeScript
const expectedContent = `// Generated version file - DO NOT EDIT
// This file is automatically generated during the build process
export const EMBEDDED_VERSION = '${testVersion}';
export const BUILD_TIMESTAMP = '${testTimestamp}';
export const PACKAGE_NAME = '${testPackageName}';
`;
// Check that content would be valid TypeScript
expect(expectedContent).toContain('export const');
expect(expectedContent).toMatch(/EMBEDDED_VERSION = '\d+\.\d+\.\d+'/);
expect(expectedContent).toContain('@dollhousemcp/mcp-server');
});
});
describe('build integration', () => {
it('should have version generation in package.json scripts', async () => {
const packageJsonPath = path.join(process.cwd(), 'package.json');
const content = await fs.readFile(packageJsonPath, 'utf-8');
const pkg = JSON.parse(content);
// Check if version generation is part of build
const hasVersionGen =
pkg.scripts?.['generate-version'] ||
pkg.scripts?.build?.includes('generate-version') ||
pkg.scripts?.prebuild?.includes('generate-version');
expect(hasVersionGen).toBeTruthy();
});
});
// VersionManager tests removed - UpdateTools and VersionManager have been removed from the codebase
});