// engine/test-mocks-generator.ts — SPEC-018 multi-language mock code generator
// Orchestrator: routes to the correct template based on testing framework.
import { MOCK_TEMPLATES } from './test-mocks-generator/mock-templates.js';
// Frameworks supported by the mock generator (superset of TestingFramework)
const SUPPORTED_FRAMEWORKS = new Set([
    'vitest',
    'jest',
    'pytest',
    'go-test',
    'junit',
    'testng',
    'cargo-test',
    'xunit',
    'nunit',
]);
/**
 * Generate mock/stub code for the given testing framework.
 *
 * @param framework - The target testing framework (e.g. 'vitest', 'pytest', 'junit').
 * @param mockTargets - Names of modules/classes/interfaces to mock.
 * @param specTitle - Title of the spec, used as the describe/class name.
 * @returns A string of ready-to-use mock code for the chosen framework.
 */
export function generateMockCode(framework, mockTargets, specTitle) {
    const targets = mockTargets.length > 0 ? mockTargets : ['ExampleService'];
    const templateFn = MOCK_TEMPLATES[framework];
    if (templateFn === undefined || !SUPPORTED_FRAMEWORKS.has(framework)) {
        return generateFallbackMock(framework, targets, specTitle);
    }
    return templateFn(targets, specTitle);
}
function generateFallbackMock(framework, targets, title) {
    const items = targets.map((t) => `  // TODO: mock ${t}`).join('\n');
    return [
        `// ${title} — mock setup for ${framework}`,
        `// Framework '${framework}' does not have a built-in template.`,
        '// Refer to the framework documentation for mock patterns.',
        '',
        `// Targets to mock:`,
        items,
        '',
    ].join('\n');
}
/**
 * Returns true if the criteria text mentions mock-related patterns,
 * suggesting that a mock example should be included in the scaffold.
 */
export function criteriaContainsMockKeyword(criteria) {
    const mockKeywords = ['mock', 'stub', 'fake', 'double', 'spy', 'patch'];
    return criteria.some((c) => mockKeywords.some((kw) => c.toLowerCase().includes(kw)));
}
//# sourceMappingURL=test-mocks-generator.js.map