import { describe, it, expect, beforeEach, afterEach } from 'vitest'

describe('main', () => {
  let appRoot

  beforeEach(() => {
    appRoot = document.createElement('div')
    appRoot.id = 'app'
    document.body.innerHTML = ''
    document.body.appendChild(appRoot)
  })

  afterEach(() => {
    document.body.innerHTML = ''
  })

  it('mounts App to #app and exports the app instance', async () => {
    const main = await import('./main.js')
    expect(main.default).toBeDefined()
    expect(main.default).toHaveProperty('$destroy')
    expect(appRoot.hasChildNodes()).toBe(true)
  })
})
