// Test setup file for Vitest
import { vi } from 'vitest'

// Mock PapaParse (since it's loaded via CDN)
global.Papa = {
  parse: vi.fn()
}

// Mock fetch for loading files
global.fetch = vi.fn()

// Setup DOM helpers
beforeEach(() => {
  // Reset DOM
  document.head.innerHTML = ''
  document.body.innerHTML = ''

  // Clear all mocks
  vi.clearAllMocks()
})

// Create helper functions for DOM setup
export const createMockElement = (tagName, attributes = {}) => {
  const element = document.createElement(tagName)
  Object.entries(attributes).forEach(([key, value]) => {
    element.setAttribute(key, value)
  })
  return element
}

export const setupBasicDOM = () => {
  document.body.innerHTML = `
    <div id="projectName"></div>
    <div id="projectSubtitle"></div>
    <div id="viewer"></div>
    <link id="dynamicCss" rel="stylesheet" href="">
    <button id="downloadSvg"></button>
    <span id="projectFile"></span>
    <span id="csvFile"></span>
    <span id="svgFile"></span>
    <span id="cssFile"></span>
  `
}