mirror of
https://github.com/unjs/unplugin.git
synced 2025-12-08 20:26:33 +00:00
test: remove this.parse test
This commit is contained in:
parent
f4cf1c59fc
commit
37a74bd133
@ -189,29 +189,6 @@ describe('bun utils', () => {
|
||||
expect(mockWriteFileSync).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should parse code with acorn', () => {
|
||||
const mockBuild = { config: { outdir: '/path/to/outdir' } }
|
||||
const context = createBuildContext(mockBuild as PluginBuilder)
|
||||
|
||||
const ast = context.parse('const x = 1')
|
||||
expect(ast).toBeDefined()
|
||||
expect(ast.type).toBe('Program')
|
||||
expect((ast as any).body).toHaveLength(1)
|
||||
expect((ast as any).body[0].type).toBe('VariableDeclaration')
|
||||
})
|
||||
|
||||
it('should parse code with custom options', () => {
|
||||
const mockBuild = { config: { outdir: '/path/to/outdir' } }
|
||||
const context = createBuildContext(mockBuild as PluginBuilder)
|
||||
|
||||
const ast = context.parse('const x = 1', {
|
||||
sourceType: 'script',
|
||||
ecmaVersion: 2015,
|
||||
})
|
||||
expect(ast).toBeDefined()
|
||||
expect(ast.type).toBe('Program')
|
||||
})
|
||||
|
||||
it('should return native build context', () => {
|
||||
const mockBuild = { config: { outdir: '/path/to/outdir' } }
|
||||
const context = createBuildContext(mockBuild as PluginBuilder)
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
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()
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user