unplugin/test/unit-tests/utils/context.test.ts
Kevin Deng 40e4a049c3
feat!: remove acorn dependency and require custom parser setup
Users must now call `setParseImpl` to provide custom parsing logic before invoking `this.parse`.
Acorn has been removed as a dependency.

closes #480
2025-11-04 14:45:23 +08:00

23 lines
614 B
TypeScript

import { describe, expect, it } from 'vitest'
import { parse } from '../../../src/utils/parse'
describe('parse', () => {
it('should parse valid JavaScript code', () => {
const code = 'const x = 42;'
const result = parse(code)
expect(result).toBeDefined()
})
it('should throw an error for invalid JavaScript code', () => {
const code = 'const x = ;'
expect(() => parse(code)).toThrow()
})
it('should accept custom options', () => {
const code = 'const x = 42;'
const opts = { ecmaVersion: 2020 }
const result = parse(code, opts)
expect(result).toBeDefined()
})
})