Skip to content

Commit a7f4e66

Browse files
authored
feat: enable sugar ref take 2 for vue3-jest (#377)
1 parent f1bdac0 commit a7f4e66

File tree

13 files changed

+1782
-797
lines changed

13 files changed

+1782
-797
lines changed

e2e/3.x/babel-in-package/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"test": "jest --no-cache test.js"
88
},
99
"dependencies": {
10-
"vue": "^3.0.3"
10+
"vue": "^3.2.6"
1111
},
1212
"devDependencies": {
1313
"@babel/core": "^7.9.0",
1414
"@babel/preset-env": "^7.9.0",
15-
"@vue/compiler-sfc": "^3.0.3",
15+
"@vue/compiler-sfc": "^3.2.6",
1616
"coffeescript": "^2.3.2",
1717
"jest": "^27.0.0",
1818
"ts-jest": "^27.0.1",

e2e/3.x/basic/__snapshots__/test.js.snap

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ exports.render = void 0;
3737
var vue_1 = require(\\"vue\\");
3838
var _hoisted_1 = { class: \\"hello\\" };
3939
function render(_ctx, _cache) {
40-
return (vue_1.openBlock(), vue_1.createBlock(\\"div\\", _hoisted_1, [
41-
vue_1.createVNode(\\"h1\\", { class: _ctx.headingClasses }, vue_1.toDisplayString(_ctx.msg), 3 /* TEXT, CLASS */)
40+
return ((0, vue_1.openBlock)(), (0, vue_1.createElementBlock)(\\"div\\", _hoisted_1, [
41+
(0, vue_1.createElementVNode)(\\"h1\\", {
42+
class: (0, vue_1.normalizeClass)(_ctx.headingClasses)
43+
}, (0, vue_1.toDisplayString)(_ctx.msg), 3 /* TEXT, CLASS */)
4244
]));
4345
}
4446
exports.render = render;
@@ -82,8 +84,10 @@ exports.render = void 0;
8284
var vue_1 = require(\\"vue\\");
8385
var _hoisted_1 = { class: \\"hello\\" };
8486
function render(_ctx, _cache) {
85-
return (vue_1.openBlock(), vue_1.createBlock(\\"div\\", _hoisted_1, [
86-
vue_1.createVNode(\\"h1\\", { class: _ctx.headingClasses }, vue_1.toDisplayString(_ctx.msg), 3 /* TEXT, CLASS */)
87+
return ((0, vue_1.openBlock)(), (0, vue_1.createElementBlock)(\\"div\\", _hoisted_1, [
88+
(0, vue_1.createElementVNode)(\\"h1\\", {
89+
class: (0, vue_1.normalizeClass)(_ctx.headingClasses)
90+
}, (0, vue_1.toDisplayString)(_ctx.msg), 3 /* TEXT, CLASS */)
8791
]));
8892
}
8993
exports.render = render;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<button @click="increase">Count: {{ num }}</button>
3+
<Basic />
4+
<span>{{ msg }}</span>
5+
</template>
6+
7+
<script setup lang="ts">
8+
import Basic from './Basic.vue'
9+
10+
let num = $ref(5)
11+
const greet = () => console.log('greet')
12+
const increase = () => {
13+
greet()
14+
num.value++
15+
}
16+
const msg = 'hello world'
17+
</script>

e2e/3.x/basic/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"test": "jest --no-cache --coverage test.js"
88
},
99
"dependencies": {
10-
"vue": "^3.0.3"
10+
"vue": "^3.2.6"
1111
},
1212
"devDependencies": {
1313
"@babel/core": "^7.9.0",
1414
"@babel/preset-env": "^7.9.0",
15-
"@vue/compiler-sfc": "^3.0.3",
15+
"@vue/compiler-sfc": "^3.2.6",
1616
"babel-helper-vue-jsx-merge-props": "^2.0.3",
1717
"babel-plugin-syntax-jsx": "^6.18.0",
1818
"babel-plugin-transform-vue-jsx": "^3.7.0",

e2e/3.x/basic/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import NoScript from './components/NoScript.vue'
2020
import PugRelative from './components/PugRelativeExtends.vue'
2121
import { randomExport } from './components/NamedExport.vue'
2222
import ScriptSetup from './components/ScriptSetup.vue'
23+
import ScriptSetupSugarRef from './components/ScriptSetupSugarRef.vue'
2324
import FunctionalRenderFn from './components/FunctionalRenderFn.vue'
2425

2526
// TODO: JSX for Vue 3? TSX?
@@ -44,6 +45,12 @@ test('supports <script setup>', () => {
4445
expect(document.body.outerHTML).toContain('Welcome to Your Vue.js App')
4546
})
4647

48+
test('supports <script setup> with sugar ref', () => {
49+
mount(ScriptSetupSugarRef)
50+
expect(document.body.outerHTML).toContain('Count: 5')
51+
expect(document.body.outerHTML).toContain('Welcome to Your Vue.js App')
52+
})
53+
4754
test('processes .vue files', () => {
4855
mount(Basic)
4956
expect(document.querySelector('h1').textContent).toBe(

e2e/3.x/custom-transformers/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test": "jest --no-cache --coverage test.js"
88
},
99
"dependencies": {
10-
"@vue/compiler-sfc": "^3.0.3",
11-
"vue": "^3.0.3"
10+
"@vue/compiler-sfc": "^3.2.6",
11+
"vue": "^3.2.6"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "^7.9.0",

e2e/3.x/javascript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "jest --no-cache test.js"
88
},
99
"dependencies": {
10-
"vue": "^3.0.3"
10+
"vue": "^3.2.6"
1111
},
1212
"devDependencies": {
1313
"@babel/core": "^7.9.0",

e2e/3.x/style/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test": "jest --no-cache test.js"
88
},
99
"dependencies": {
10-
"@vue/compiler-sfc": "^3.0.3",
11-
"vue": "^3.0.3"
10+
"@vue/compiler-sfc": "^3.2.6",
11+
"vue": "^3.2.6"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "^7.9.0",

e2e/3.x/typescript-with-babel/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test": "jest --no-cache ./sub-project/test.js"
88
},
99
"dependencies": {
10-
"@vue/compiler-sfc": "^3.0.3",
11-
"vue": "^3.0.3"
10+
"@vue/compiler-sfc": "^3.2.6",
11+
"vue": "^3.2.6"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "^7.9.0",

e2e/3.x/typescript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test": "jest --no-cache ./src/test.ts"
88
},
99
"dependencies": {
10-
"@vue/compiler-sfc": "^3.0.3",
11-
"vue": "^3.0.3"
10+
"@vue/compiler-sfc": "^3.2.6",
11+
"vue": "^3.2.6"
1212
},
1313
"devDependencies": {
1414
"@types/jest": "16.0.10",

0 commit comments

Comments
 (0)