/
hoistStatic.spec.ts.snap
145 lines (103 loc) 路 2.29 KB
/
hoistStatic.spec.ts.snap
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`sfc hoist static > should enable when only script setup 1`] = `
"const foo = 'bar'
export default {
setup(__props) {
const foo = 'bar'
return () => {}
}
}"
`;
exports[`sfc hoist static > should hoist expressions 1`] = `
"const unary = !false
const binary = 1 + 2
const conditional = 1 ? 2 : 3
const sequence = (1, true, 'foo', 1)
export default {
setup(__props) {
return () => {}
}
}"
`;
exports[`sfc hoist static > should hoist literal value 1`] = `
"const string = 'default value'
const number = 123
const boolean = false
const nil = null
const bigint = 100n
const template = \`str\`
export default {
setup(__props) {
return () => {}
}
}"
`;
exports[`sfc hoist static > should hoist w/ defineProps/Emits 1`] = `
"const defaultValue = 'default value'
export default {
props: {
foo: {
default: defaultValue
}
},
setup(__props) {
return () => {}
}
}"
`;
exports[`sfc hoist static > should not hoist a constant initialized to a reference value 1`] = `
"import { defineComponent as _defineComponent } from 'vue'
export default /*#__PURE__*/_defineComponent({
setup(__props) {
const KEY1 = Boolean
const KEY2 = [Boolean]
const KEY3 = [getCurrentInstance()]
let i = 0;
const KEY4 = (i++, 'foo')
enum KEY5 {
FOO = 1,
BAR = getCurrentInstance(),
}
const KEY6 = \`template\${i}\`
return () => {}
}
})"
`;
exports[`sfc hoist static > should not hoist a function or class 1`] = `
"export default {
setup(__props) {
const fn = () => {}
function fn2() {}
class Foo {}
return () => {}
}
}"
`;
exports[`sfc hoist static > should not hoist a object or array 1`] = `
"export default {
setup(__props) {
const obj = { foo: 'bar' }
const arr = [1, 2, 3]
return () => {}
}
}"
`;
exports[`sfc hoist static > should not hoist a variable 1`] = `
"export default {
setup(__props) {
let KEY1 = 'default value'
var KEY2 = 123
const regex = /.*/g
const undef = undefined
return () => {}
}
}"
`;
exports[`sfc hoist static > should not hoist when disabled 1`] = `
"export default {
setup(__props) {
const foo = 'bar'
return () => {}
}
}"
`;