let foo = $ref(1)
</script>
`,
- { refTransform: true }
+ { reactivityTransform: true }
)
assertCode(content)
expect(content).toMatch(`import { ref } from 'vue'`)
describe('async/await detection', () => {
function assertAwaitDetection(code: string, shouldAsync = true) {
const { content } = compile(`<script setup>${code}</script>`, {
- refTransform: true
+ reactivityTransform: true
})
if (shouldAsync) {
expect(content).toMatch(`let __temp, __restore`)
// this file only tests integration with SFC - main test case for the ref
// transform can be found in <root>/packages/reactivity-transform/__tests__
describe('sfc ref transform', () => {
- function compileWithRefTransform(src: string) {
- return compile(src, { refTransform: true })
+ function compileWithReactivityTransform(src: string) {
+ return compile(src, { reactivityTransform: true })
}
test('$ unwrapping', () => {
- const { content, bindings } = compileWithRefTransform(`<script setup>
+ const { content, bindings } = compileWithReactivityTransform(`<script setup>
import { ref, shallowRef } from 'vue'
let foo = $(ref())
let a = $(ref(1))
})
test('$ref & $shallowRef declarations', () => {
- const { content, bindings } = compileWithRefTransform(`<script setup>
+ const { content, bindings } = compileWithReactivityTransform(`<script setup>
let foo = $ref()
let a = $ref(1)
let b = $shallowRef({
})
test('usage in normal <script>', () => {
- const { content } = compileWithRefTransform(`<script>
+ const { content } = compileWithReactivityTransform(`<script>
export default {
setup() {
let count = $ref(0)
})
test('usage /w typescript', () => {
- const { content } = compileWithRefTransform(`
+ const { content } = compileWithReactivityTransform(`
<script setup lang="ts">
let msg = $ref<string | number>('foo');
let bar = $ref <string | number>('bar');
})
test('usage with normal <script> + <script setup>', () => {
- const { content, bindings } = compileWithRefTransform(`<script>
+ const { content, bindings } = compileWithReactivityTransform(`<script>
let a = $ref(0)
let c = $ref(0)
</script>
bar
})
</script>`,
- { refTransform: true }
+ { reactivityTransform: true }
)
).toThrow(`cannot reference locally declared variables`)
bar
})
</script>`,
- { refTransform: true }
+ { reactivityTransform: true }
)
).toThrow(`cannot reference locally declared variables`)
})