@@ -22,12 +22,13 @@ describe('useAccessStore', () => {
22
22
const tab : any = {
23
23
fullPath : '/home' ,
24
24
meta : { } ,
25
+ key : '/home' ,
25
26
name : 'Home' ,
26
27
path : '/home' ,
27
28
} ;
28
- store . addTab ( tab ) ;
29
+ const addNewTab = store . addTab ( tab ) ;
29
30
expect ( store . tabs . length ) . toBe ( 1 ) ;
30
- expect ( store . tabs [ 0 ] ) . toEqual ( tab ) ;
31
+ expect ( store . tabs [ 0 ] ) . toEqual ( addNewTab ) ;
31
32
} ) ;
32
33
33
34
it ( 'adds a new tab if it does not exist' , ( ) => {
@@ -38,20 +39,22 @@ describe('useAccessStore', () => {
38
39
name : 'New' ,
39
40
path : '/new' ,
40
41
} ;
41
- store . addTab ( newTab ) ;
42
- expect ( store . tabs ) . toContainEqual ( newTab ) ;
42
+ const addNewTab = store . addTab ( newTab ) ;
43
+ expect ( store . tabs ) . toContainEqual ( addNewTab ) ;
43
44
} ) ;
44
45
45
46
it ( 'updates an existing tab instead of adding a new one' , ( ) => {
46
47
const store = useTabbarStore ( ) ;
47
48
const initialTab : any = {
48
49
fullPath : '/existing' ,
49
- meta : { } ,
50
+ meta : {
51
+ fullPathKey : false ,
52
+ } ,
50
53
name : 'Existing' ,
51
54
path : '/existing' ,
52
55
query : { } ,
53
56
} ;
54
- store . tabs . push ( initialTab ) ;
57
+ store . addTab ( initialTab ) ;
55
58
const updatedTab = { ...initialTab , query : { id : '1' } } ;
56
59
store . addTab ( updatedTab ) ;
57
60
expect ( store . tabs . length ) . toBe ( 1 ) ;
@@ -60,9 +63,12 @@ describe('useAccessStore', () => {
60
63
61
64
it ( 'closes all tabs' , async ( ) => {
62
65
const store = useTabbarStore ( ) ;
63
- store . tabs = [
64
- { fullPath : '/home' , meta : { } , name : 'Home' , path : '/home' } ,
65
- ] as any ;
66
+ store . addTab ( {
67
+ fullPath : '/home' ,
68
+ meta : { } ,
69
+ name : 'Home' ,
70
+ path : '/home' ,
71
+ } as any ) ;
66
72
router . replace = vi . fn ( ) ;
67
73
68
74
await store . closeAllTabs ( router ) ;
@@ -157,7 +163,7 @@ describe('useAccessStore', () => {
157
163
path : '/contact' ,
158
164
} as any ) ;
159
165
160
- await store . _bulkCloseByPaths ( [ '/home' , '/contact' ] ) ;
166
+ await store . _bulkCloseByKeys ( [ '/home' , '/contact' ] ) ;
161
167
162
168
expect ( store . tabs ) . toHaveLength ( 1 ) ;
163
169
expect ( store . tabs [ 0 ] ?. name ) . toBe ( 'About' ) ;
@@ -183,9 +189,8 @@ describe('useAccessStore', () => {
183
189
name : 'Contact' ,
184
190
path : '/contact' ,
185
191
} ;
186
- store . addTab ( targetTab ) ;
187
-
188
- await store . closeLeftTabs ( targetTab ) ;
192
+ const addTargetTab = store . addTab ( targetTab ) ;
193
+ await store . closeLeftTabs ( addTargetTab ) ;
189
194
190
195
expect ( store . tabs ) . toHaveLength ( 1 ) ;
191
196
expect ( store . tabs [ 0 ] ?. name ) . toBe ( 'Contact' ) ;
@@ -205,15 +210,15 @@ describe('useAccessStore', () => {
205
210
name : 'About' ,
206
211
path : '/about' ,
207
212
} ;
208
- store . addTab ( targetTab ) ;
213
+ const addTargetTab = store . addTab ( targetTab ) ;
209
214
store . addTab ( {
210
215
fullPath : '/contact' ,
211
216
meta : { } ,
212
217
name : 'Contact' ,
213
218
path : '/contact' ,
214
219
} as any ) ;
215
220
216
- await store . closeOtherTabs ( targetTab ) ;
221
+ await store . closeOtherTabs ( addTargetTab ) ;
217
222
218
223
expect ( store . tabs ) . toHaveLength ( 1 ) ;
219
224
expect ( store . tabs [ 0 ] ?. name ) . toBe ( 'About' ) ;
@@ -227,7 +232,7 @@ describe('useAccessStore', () => {
227
232
name : 'Home' ,
228
233
path : '/home' ,
229
234
} ;
230
- store . addTab ( targetTab ) ;
235
+ const addTargetTab = store . addTab ( targetTab ) ;
231
236
store . addTab ( {
232
237
fullPath : '/about' ,
233
238
meta : { } ,
@@ -241,7 +246,7 @@ describe('useAccessStore', () => {
241
246
path : '/contact' ,
242
247
} as any ) ;
243
248
244
- await store . closeRightTabs ( targetTab ) ;
249
+ await store . closeRightTabs ( addTargetTab ) ;
245
250
246
251
expect ( store . tabs ) . toHaveLength ( 1 ) ;
247
252
expect ( store . tabs [ 0 ] ?. name ) . toBe ( 'Home' ) ;
0 commit comments