Skip to content

Commit 5316df6

Browse files
committed
test: remove node transformer
1 parent 293b068 commit 5316df6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/remove-node.test.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { isCallOf } from 'ast-kit'
2+
import { expect, test } from 'vitest'
3+
import { transform } from '../src/core/transform'
4+
import { RemoveNode } from '../src/transformers'
5+
import type { OptionsResolved } from '../src/core/options'
6+
7+
test('remove node', async () => {
8+
const source = `const comp = defineComponent({
9+
render() {
10+
return []
11+
}
12+
})
13+
console.log(mutable({} as const))
14+
`
15+
16+
const options: Pick<OptionsResolved, 'parserOptions' | 'transformer'> = {
17+
transformer: [
18+
RemoveNode(
19+
(node) => node.type === 'ReturnStatement' || isCallOf(node, 'mutable'),
20+
),
21+
],
22+
parserOptions: {},
23+
}
24+
const code = (await transform(source, 'foo.ts', options))?.code
25+
expect(code).toMatchInlineSnapshot(`
26+
"const comp = defineComponent({
27+
render() {
28+
29+
}
30+
})
31+
console.log()
32+
"
33+
`)
34+
})

0 commit comments

Comments
 (0)