// tools/generate-tests-content.ts — Test scaffold content generators
// Pure functions that return test file content strings
import { generateXCTestContent, generateAndroidTestContent } from './generate-tests-mobile.js';
function toPascal(str) {
    return str
        .replace(/[^a-zA-Z0-9\s]/g, '')
        .split(/\s+/)
        .map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
        .join('');
}
export function generateUnitTestContent(title, _target, framework, language) {
    if (language === 'swift' || framework === 'xctest') {
        return generateXCTestContent(title, 'unit');
    }
    if (language === 'kotlin' && framework.includes('junit')) {
        return generateAndroidTestContent(title, 'unit', 'compose', 'mockk');
    }
    if (framework === 'pytest') {
        return `# Unit tests for: ${title}
# Generated by Planu SDD MCP Server

import pytest


class Test${toPascal(title)}:
    """Unit tests for ${title}."""

    def test_core_logic(self):
        """Test core business logic."""
        # TODO: Implement test
        assert True

    def test_edge_cases(self):
        """Test edge cases and boundary conditions."""
        # TODO: Implement test
        assert True

    def test_error_handling(self):
        """Test error handling scenarios."""
        # TODO: Implement test
        with pytest.raises(Exception):
            pass  # TODO: Call function that should raise

    def test_input_validation(self):
        """Test input validation."""
        # TODO: Implement test
        assert True
`;
    }
    // Default: vitest/jest style
    return `// Unit tests for: ${title}
// Generated by Planu SDD MCP Server

import { describe, it, expect } from '${framework}';

describe('${title}', () => {
  describe('core logic', () => {
    it('should handle the primary use case', () => {
      // TODO: Implement test
      expect(true).toBe(true);
    });

    it('should handle edge cases', () => {
      // TODO: Implement test
      expect(true).toBe(true);
    });
  });

  describe('error handling', () => {
    it('should throw on invalid input', () => {
      // TODO: Implement test
      expect(() => {
        // Call function with invalid input
      }).toThrow();
    });
  });

  describe('validation', () => {
    it('should validate required fields', () => {
      // TODO: Implement test
      expect(true).toBe(true);
    });
  });
});
`;
}
export function generateIntegrationTestContent(title, framework, _language) {
    if (framework === 'pytest') {
        return `# Integration tests for: ${title}
# Generated by Planu SDD MCP Server

import pytest


@pytest.fixture
def setup_db():
    """Set up test database."""
    # TODO: Setup
    yield
    # TODO: Teardown


class Test${toPascal(title)}Integration:
    """Integration tests for ${title}."""

    def test_api_endpoint(self, setup_db):
        """Test API endpoint integration."""
        # TODO: Implement test
        assert True

    def test_database_operations(self, setup_db):
        """Test database CRUD operations."""
        # TODO: Implement test
        assert True
`;
    }
    return `// Integration tests for: ${title}
// Generated by Planu SDD MCP Server

import { describe, it, expect, beforeAll, afterAll } from '${framework}';

describe('${title} — Integration', () => {
  beforeAll(async () => {
    // TODO: Setup test environment (database, services, etc.)
  });

  afterAll(async () => {
    // TODO: Cleanup test environment
  });

  it('should handle API requests correctly', async () => {
    // TODO: Implement integration test
    expect(true).toBe(true);
  });

  it('should persist data correctly', async () => {
    // TODO: Implement database integration test
    expect(true).toBe(true);
  });
});
`;
}
export function generateE2eTestContent(title, framework) {
    if (framework === 'cypress') {
        return `// E2E tests for: ${title}
// Generated by Planu SDD MCP Server

describe('${title}', () => {
  beforeEach(() => {
    cy.visit('/');
  });

  it('should complete the user flow', () => {
    // TODO: Implement E2E test
    cy.get('body').should('exist');
  });
});
`;
    }
    // Default: Playwright
    return `// E2E tests for: ${title}
// Generated by Planu SDD MCP Server

import { test, expect } from '@playwright/test';

test.describe('${title}', () => {
  test('should complete the user flow', async ({ page }) => {
    await page.goto('/');

    // TODO: Implement E2E test
    await expect(page).toHaveTitle(/.*/);
  });
});
`;
}
export function buildTestCommands(existingCmd, framework) {
    const commands = [];
    if (existingCmd) {
        commands.push(`# Run all tests`);
        commands.push(existingCmd);
    }
    const frameworkCmds = {
        vitest: ['npx vitest run', 'npx vitest run --coverage'],
        jest: ['npx jest', 'npx jest --coverage'],
        pytest: ['pytest', 'pytest --cov'],
        'go-test': ['go test ./...', 'go test -cover ./...'],
        'cargo-test': ['cargo test'],
    };
    const cmds = frameworkCmds[framework];
    if (cmds) {
        commands.push(`# ${framework} commands`);
        commands.push(...cmds);
    }
    return commands;
}
//# sourceMappingURL=generate-tests-content.js.map