unplugin/test/unit-tests/utils/context.test.ts
Kanon 0415fb5a59
test: add test for rolldown/unloader/utils (#493)
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
2025-04-10 04:20:41 +08:00

23 lines
616 B
TypeScript

import { describe, expect, it } from 'vitest'
import { parse } from '../../../src/utils/context'
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()
})
})