import MagicString, { SourceMap } from 'magic-string'
import { describe, expect, it } from 'vitest'
import { MagicSFC, createSourceLocation, proxyBlock } from '../src'
describe('Magic SFC', () => {
it('Can create the class', () => {
const sfc = new MagicSFC('')
expect(sfc.toString()).toBe('')
})
it('Can create the class from a MagicString', () => {
const ms = new MagicString('')
const sfc = new MagicSFC(ms)
expect(sfc.toString()).toBe('')
})
it('Can get a sourcemap', () => {
const sfc = new MagicSFC('')
expect(sfc.getSourcemap()).toBeInstanceOf(SourceMap)
})
it('Can access custom properties from proxified block', () => {
const source = ''
const block = proxyBlock(
new MagicString(source),
{
loc: createSourceLocation(source),
type: 'style',
lang: 'postcss',
attrs: {
lang: 'postcss',
},
},
)
expect(block.type).toBe('style')
})
})