/**
 * @fileoverview Integration tests for OrdoJS Compiler components
 */

import { describe, expect, it } from 'vitest';
import { type ComponentAST } from '../types/index.js';
import { OrdoJSCodeGenerator } from './code-generator.js';

describe('OrdoJS Compiler Integration', () => {
  it('should generate code from a simple AST', () => {
    // Create a simple AST manually
    const ast: ComponentAST = {
      component: {
        type: 'Component',
        name: 'SimpleComponent',
        props: [],
        markupBlock: {
          type: 'MarkupBlock',
          elements: [
            {
              type: 'HTMLElement',
              tagName: 'div',
              attributes: [],
              children: [
                {
                  type: 'Text',
                  content: 'Hello, World!',
                  range: { start: { line: 1, column: 1, offset: 0 }, end: { line: 1, column: 1, offset: 0 } }
                }
              ],
              isSelfClosing: false,
              isVoidElement: false,
              range: { start: { line: 1, column: 1, offset: 0 }, end: { line: 1, column: 1, offset: 0 } }
            }
          ],
          textNodes: [],
          interpolations: [],
          range: { start: { line: 1, column: 1, offset: 0 }, end: { line: 1, column: 1, offset: 0 } }
        },
        range: { start: { line: 1, column: 1, offset: 0 }, end: { line: 1, column: 1, offset: 0 } }
      },
      dependencies: [],
      exports: [],
      sourceMap: {
        version: 3,
        sources: [],
        names: [],
        mappings: '',
        sourcesContent: []
      }
    };

    // Generate code
    const generator = new OrdoJSCodeGenerator();
    const result = generator.generate(ast);

    // Verify the generated code
    expect(result.client).toContain('function SimpleComponent(props = {})');
    expect(result.client).toContain('document.createElement("div")');
    expect(result.client).toContain('Hello, World!');
    expect(result.html).toContain('<div data-ordojs-hydrate="true">Hello, World!</div>');
    expect(result.html).toContain('data-ordojs-component="SimpleComponent"');
  });
});
