Skip to content

Commit 560ee7c

Browse files
committed
wip: script setup
1 parent 26387ab commit 560ee7c

File tree

8 files changed

+545
-247
lines changed

8 files changed

+545
-247
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<button @click="increase">Count: {{ num }}</button>
3+
<span>{{ msg }}</span>
4+
</template>
5+
6+
<script setup="props, { emit }" lang="ts">
7+
import { ref } from 'vue'
8+
export const num = ref(5)
9+
const greet = () => console.log('greet')
10+
export const increase = () => {
11+
greet()
12+
num.value++
13+
}
14+
export const msg = 'hello world'
15+
</script>

e2e/__projects__/basic/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"test": "jest --no-cache --coverage test.js"
99
},
1010
"dependencies": {
11-
"vue": "3.0.0-alpha.10"
11+
"vue": "^3.0.0"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "^7.2.2",
1515
"@babel/preset-env": "^7.2.3",
16-
"@vue/compiler-sfc": "3.0.0-alpha.10",
16+
"@vue/compiler-sfc": "^3.0.0",
1717
"babel-helper-vue-jsx-merge-props": "^2.0.3",
1818
"babel-plugin-syntax-jsx": "^6.18.0",
1919
"babel-plugin-transform-vue-jsx": "^3.7.0",

e2e/__projects__/basic/test.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@ import { createApp, h } from 'vue'
22
import { resolve } from 'path'
33
import { readFileSync } from 'fs'
44

5-
import BasicSrc from './components/BasicSrc.vue'
6-
import Pug from './components/Pug.vue'
7-
import Coffee from './components/Coffee.vue'
8-
import Basic from './components/Basic.vue'
9-
import TypeScript from './components/TypeScript.vue'
10-
import jestVue from '../../../'
11-
import RenderFunction from './components/RenderFunction.vue'
12-
import FunctionalSFC from './components/FunctionalSFC.vue'
13-
import CoffeeScript from './components/CoffeeScript.vue'
14-
import FunctionalSFCParent from './components/FunctionalSFCParent.vue'
15-
import NoScript from './components/NoScript.vue'
16-
import PugRelative from './components/PugRelativeExtends.vue'
17-
import { randomExport } from './components/NamedExport.vue'
5+
// import BasicSrc from './components/BasicSrc.vue'
6+
// import Pug from './components/Pug.vue'
7+
// import Coffee from './components/Coffee.vue'
8+
// import Basic from './components/Basic.vue'
9+
// import TypeScript from './components/TypeScript.vue'
10+
// import jestVue from '../../../'
11+
// import RenderFunction from './components/RenderFunction.vue'
12+
// import FunctionalSFC from './components/FunctionalSFC.vue'
13+
// import CoffeeScript from './components/CoffeeScript.vue'
14+
// import FunctionalSFCParent from './components/FunctionalSFCParent.vue'
15+
// import NoScript from './components/NoScript.vue'
16+
// import PugRelative from './components/PugRelativeExtends.vue'
17+
// import { randomExport } from './components/NamedExport.vue'
18+
import ScriptSetup from './components/ScriptSetup.vue'
1819

1920
// TODO: JSX for Vue 3? TSX?
20-
import Jsx from './components/Jsx.vue'
21+
// import Jsx from './components/Jsx.vue'
2122

2223
function mount(Component, props, slots) {
2324
document.getElementsByTagName('html')[0].innerHTML = ''
@@ -32,6 +33,11 @@ function mount(Component, props, slots) {
3233
createApp(Parent).mount(el)
3334
}
3435

36+
test.only('supports <script setup>', () => {
37+
mount(ScriptSetup)
38+
expect(document.body.outerHTML).toContain('Count: 5')
39+
})
40+
3541
test('processes .vue files', () => {
3642
mount(Basic)
3743
expect(document.querySelector('h1').textContent).toBe(

0 commit comments

Comments
 (0)