File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ <script setup lang="ts">
2
+ // imported components are also directly usable in template
3
+ import { ref } from ' vue'
4
+
5
+ // write Composition API code just like in a normal setup()
6
+ // but no need to manually return everything
7
+ const count = ref (0 )
8
+ const inc = () => { count .value ++ }
9
+ </script >
10
+
11
+ <template >
12
+ <button @click =" inc" >{{ count }}</button >
13
+ </template >
Original file line number Diff line number Diff line change 1
1
import { mount } from '../../src'
2
2
import Hello from '../components/Hello.vue'
3
+ import ScriptSetup from '../components/ScriptSetup.vue'
3
4
4
5
describe ( 'sfc' , ( ) => {
5
6
it ( 'mounts an sfc via vue-test-transformer' , ( ) => {
6
7
const wrapper = mount ( Hello )
7
8
expect ( wrapper . find ( '#msg' ) . text ( ) ) . toBe ( 'Hello world' )
8
9
} )
10
+
11
+ // rfc: https://github.com/vuejs/rfcs/pull/228
12
+ it ( 'works with <script setup> (as of Vue 3.0.3)' , async ( ) => {
13
+ const wrapper = mount ( ScriptSetup )
14
+ await wrapper . find ( 'button' ) . trigger ( 'click' )
15
+ expect ( wrapper . html ( ) ) . toContain ( '1' )
16
+ } )
9
17
} )
You can’t perform that action at this time.
0 commit comments