-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathremove-node.test.ts
More file actions
35 lines (32 loc) · 891 Bytes
/
Copy pathremove-node.test.ts
File metadata and controls
35 lines (32 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { expect, test } from 'vitest'
import { transform } from '../src/core/transform.ts'
import { RemoveNode } from '../src/transformers.ts'
import { ast } from '../src/yuku.ts'
import type { OptionsResolved } from '../src/core/options.ts'
test('remove node', async () => {
const source = `const comp = defineComponent({
render() {
return []
}
})
console.log(mutable({} as const))
`
const options: Pick<OptionsResolved, 'parserOptions' | 'transformer'> = {
transformer: [
RemoveNode(
(node) =>
node.type === 'ReturnStatement' || ast.isCallOf(node, 'mutable'),
),
],
parserOptions: {},
}
const code = (await transform(source, 'foo.ts', options))?.toString()
expect(code).toMatchInlineSnapshot(`
"const comp = defineComponent({
render() {
}
})
console.log()
"
`)
})