Skip to content

Commit d4787e5

Browse files
committedJun 15, 2022
test: test case for prefixIdentifiers w/ bindings
1 parent 452aa9d commit d4787e5

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
 

Diff for: ‎packages/compiler-sfc/test/prefixIdentifiers.spec.ts

+39
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { prefixIdentifiers } from '../src/prefixIdentifiers'
22
import { compile } from 'web/entry-compiler'
33
import { format } from 'prettier'
4+
import { BindingTypes } from '../src/types'
45

56
it('should work', () => {
67
const { render } = compile(`<div id="app">
@@ -53,3 +54,41 @@ it('should work', () => {
5354
"
5455
`)
5556
})
57+
58+
it('setup bindings', () => {
59+
const { render } = compile(`<div @click="count++">{{ count }}</div>`)
60+
61+
const result = format(
62+
prefixIdentifiers(render, `render`, false, false, undefined, {
63+
count: BindingTypes.SETUP_REF
64+
}),
65+
{
66+
semi: false,
67+
parser: 'babel'
68+
}
69+
)
70+
71+
expect(result).toMatch(`_setup = _vm._setupProxy`)
72+
expect(result).toMatch(`_setup.count++`)
73+
expect(result).toMatch(`_vm._s(_setup.count)`)
74+
75+
expect(result).toMatchInlineSnapshot(`
76+
"function render() {
77+
var _vm = this,
78+
_c = _vm._self._c,
79+
_setup = _vm._setupProxy
80+
return _c(
81+
\\"div\\",
82+
{
83+
on: {
84+
click: function (\$event) {
85+
_setup.count++
86+
},
87+
},
88+
},
89+
[_vm._v(_vm._s(_setup.count))]
90+
)
91+
}
92+
"
93+
`)
94+
})

0 commit comments

Comments
 (0)
Please sign in to comment.