mirror of
https://github.com/unjs/unplugin.git
synced 2025-12-08 20:26:33 +00:00
Users must now call `setParseImpl` to provide custom parsing logic before invoking `this.parse`. Acorn has been removed as a dependency. closes #480
23 lines
614 B
TypeScript
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()
|
|
})
|
|
})
|