@@ -4,16 +4,14 @@ import { defineComponent } from 'vue'
44
55describe ( 'Multiple Roots' , ( ) => {
66 function defineMyStore ( ) {
7- return defineStore ( {
8- id : 'main' ,
7+ return defineStore ( 'main' , {
98 state : ( ) => ( {
109 n : 0 ,
1110 } ) ,
1211 } )
1312 }
1413
1514 it ( 'uses the same root in child components by default' , ( ) => {
16- expect . assertions ( 2 )
1715 const pinia = createPinia ( )
1816 const useStore = defineMyStore ( )
1917
@@ -37,10 +35,12 @@ describe('Multiple Roots', () => {
3735 } ,
3836 { global : { plugins : [ pinia ] } }
3937 )
38+
39+ const store = useStore ( )
40+ expect ( store . n ) . toBe ( 1 )
4041 } )
4142
4243 it ( 'can use a new pinia root for all child components' , async ( ) => {
43- expect . assertions ( 2 )
4444 const pinia = createPinia ( )
4545 const useStore = defineMyStore ( )
4646
@@ -64,35 +64,8 @@ describe('Multiple Roots', () => {
6464 } ,
6565 { global : { plugins : [ pinia ] } }
6666 )
67- } )
68-
69- it ( 'state is shared between child components' , async ( ) => {
70- expect . assertions ( 3 )
71- const pinia = createPinia ( )
72- const useStore = defineMyStore ( )
7367
74- const ChildComponent = defineComponent ( {
75- template : 'no' ,
76- props : { counter : { type : Number , required : true } } ,
77- setup ( props : { counter : number } ) {
78- const store = useStore ( )
79- expect ( store . n ) . toBe ( props . counter )
80- store . n ++
81- } ,
82- } )
83- mount (
84- {
85- template :
86- '<ChildComponent :counter="0" /><ChildComponent :counter="1" />' ,
87- components : { ChildComponent } ,
88- setup ( ) {
89- const store = useStore ( )
90- expect ( store . n ) . toBe ( 0 )
91- store . n ++
92- providePinia ( createPinia ( ) )
93- } ,
94- } ,
95- { global : { plugins : [ pinia ] } }
96- )
68+ const store = useStore ( )
69+ expect ( store . n ) . toBe ( 0 )
9770 } )
9871} )
0 commit comments